2020-04-07 19:08:31 +00:00
|
|
|
require "./infoparser.cr"
|
2020-04-07 19:18:36 +00:00
|
|
|
require "./issue.cr"
|
2020-03-28 20:02:55 +00:00
|
|
|
|
|
|
|
module Muse::Dl
|
2020-04-07 19:08:31 +00:00
|
|
|
class Journal
|
2020-06-30 13:06:01 +00:00
|
|
|
getter :info, :summary, :publisher, :issues, :title
|
2020-04-07 19:08:31 +00:00
|
|
|
@info = Hash(String, String).new
|
|
|
|
@summary : String
|
|
|
|
@publisher : String
|
2020-04-07 19:18:36 +00:00
|
|
|
@issues = [] of Muse::Dl::Issue
|
2020-06-30 13:06:01 +00:00
|
|
|
@title : String
|
2020-04-07 19:08:31 +00:00
|
|
|
|
|
|
|
private getter :h
|
|
|
|
|
|
|
|
def initialize(html)
|
|
|
|
@h = Myhtml::Parser.new html
|
|
|
|
@info = InfoParser.infobox(h)
|
|
|
|
@summary = InfoParser.summary(h)
|
|
|
|
@publisher = InfoParser.journal_publisher(h)
|
2020-06-30 13:06:01 +00:00
|
|
|
@title = InfoParser.journal_title(h)
|
2020-04-07 19:18:36 +00:00
|
|
|
parse_volumes(h)
|
|
|
|
end
|
|
|
|
|
2020-06-30 12:29:56 +00:00
|
|
|
def open_access
|
|
|
|
if @info.has_key? "Open Access"
|
|
|
|
return @info["Open Access"] == "Yes"
|
|
|
|
end
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2020-04-07 19:18:36 +00:00
|
|
|
def parse_volumes(myhtml : Myhtml::Parser)
|
|
|
|
myhtml.css("#available_issues_list_text a").each do |a|
|
|
|
|
link = a.attribute_by("href").to_s
|
|
|
|
|
|
|
|
matches = /\/issue\/(\d+)/.match link
|
|
|
|
if matches
|
2020-06-30 13:06:01 +00:00
|
|
|
issue = Muse::Dl::Issue.new matches[1]
|
|
|
|
issue.journal_title = @title
|
|
|
|
@issues.push issue
|
2020-04-07 19:18:36 +00:00
|
|
|
end
|
|
|
|
end
|
2020-04-07 19:08:31 +00:00
|
|
|
end
|
2020-03-28 20:02:55 +00:00
|
|
|
end
|
|
|
|
end
|