Module: Jats::Front
- Included in:
- Article
- Defined in:
- lib/jats/front.rb
Instance Method Summary collapse
- #parse_article_categories(xml) ⇒ Object
- #parse_article_id(xml) ⇒ Object
- #parse_contrib_group(xml) ⇒ Object
- #parse_front ⇒ Object
- #parse_history(xml) ⇒ Object
- #parse_kwd_group(xml) ⇒ Object
- #parse_pub_date(xml) ⇒ Object
- #parse_title_group(xml) ⇒ Object
Instance Method Details
#parse_article_categories(xml) ⇒ Object
32 33 34 |
# File 'lib/jats/front.rb', line 32 def parse_article_categories(xml) doc[:properties][:categories] = xml.css('subject').map(&:text) end |
#parse_article_id(xml) ⇒ Object
7 8 9 10 11 |
# File 'lib/jats/front.rb', line 7 def parse_article_id(xml) if xml['pub-id-type'] == 'doi' doc[:properties][:doi] = xml.text end end |
#parse_contrib_group(xml) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jats/front.rb', line 36 def parse_contrib_group(xml) doc[:properties][:authors] ||= [] xml.css('contrib').each do |contrib| person = Person.from_xml(contrib) person.affiliation_ids.each do |rid| aff_xml = xml.css("aff[id='#{rid}']").first aff = Affiliation.from_xml(aff_xml) person.affiliations << aff.to_hash end doc[:properties][:authors] << person.id add_node(person) end end |
#parse_front ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jats/front.rb', line 57 def parse_front xml.css('article-meta').children.each do |node| next if node.text? name = node.name.gsub('-', '_') if respond_to?("parse_#{name}") self.send("parse_#{name}", node) end end doc end |
#parse_history(xml) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jats/front.rb', line 13 def parse_history(xml) xml.css('date').each do |date| type = date['date-type'] + "_on" yy = date.css('year').text mm = date.css('month').text dd = date.css('day').text doc[:properties][type.to_sym] = Date.parse("#{yy}-#{mm}-#{dd}").to_s end end |
#parse_kwd_group(xml) ⇒ Object
53 54 55 |
# File 'lib/jats/front.rb', line 53 def parse_kwd_group(xml) doc[:properties][:keywords] = xml.css('kwd').collect { |x| x.text } end |
#parse_pub_date(xml) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/jats/front.rb', line 25 def parse_pub_date(xml) yy = xml.css('year').text mm = xml.css('month').text dd = xml.css('day').text doc[:properties][:published_on] = Date.parse("#{yy}-#{mm}-#{dd}").to_s end |
#parse_title_group(xml) ⇒ Object
3 4 5 |
# File 'lib/jats/front.rb', line 3 def parse_title_group(xml) doc[:properties][:title] = xml.css('article-title').text end |