muse-dl/src/issue.cr

34 lines
790 B
Crystal
Raw Normal View History

require "./thing.cr"
2020-04-07 20:18:48 +00:00
require "./fetch.cr"
require "./article.cr"
module Muse::Dl
2020-04-07 19:18:36 +00:00
class Issue
@id : String
2020-04-07 20:18:48 +00:00
@title : String | Nil
@articles : Array(Muse::Dl::Article)
@url : String
2020-04-07 20:20:40 +00:00
@info : Hash(String, String)
2020-04-07 20:18:48 +00:00
@summary : String | Nil
@publisher : String | Nil
2020-04-07 19:18:36 +00:00
2020-04-07 20:18:48 +00:00
getter :id, :title, :articles, :url, :summary, :publisher, :info
2020-04-07 19:18:36 +00:00
def initialize(id : String)
@id = id
2020-04-07 20:18:48 +00:00
@url = "https://muse.jhu.edu/issue/#{id}"
@title = "NA"
2020-04-07 20:20:40 +00:00
@info = Hash(String, String).new
2020-04-07 20:18:48 +00:00
@articles = [] of Muse::Dl::Article
end
def parse
html = Crest.get(url).to_s
h = Myhtml::Parser.new html
@info = InfoParser.infobox(h)
@summary = InfoParser.summary(h)
@publisher = InfoParser.journal_publisher(h)
2020-04-07 19:18:36 +00:00
end
end
end