Sha256: 11e11d2ecd879993b46a2e2dea30f1a0abb555bb121f53cf88c4bec820350392
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
module GutenbergRdf class Rdf class Agent attr_reader :xml def initialize(xml) @xml = xml end def id xml.elements['pgterms:agent'].attributes['about'].match(/\A\d\d\d\d\/agents\/(\d+)\z/)[1] end def fullname [firstname, lastname].join(' ') end def lastname @lastname ||= name_parts[:last] end def firstname @firstname ||= name_parts[:first] end def birthdate xml.elements['pgterms:agent/pgterms:birthdate'].text end def deathdate xml.elements['pgterms:agent/pgterms:deathdate'].text end def webpage xml.elements['pgterms:agent/pgterms:webpage'].attributes['resource'] end def aliases entries = Array.new xml.elements.each('pgterms:agent/pgterms:alias') do |name| entries << name.text end entries end private def name_parts parts = xml.elements['pgterms:agent/pgterms:name'].text.split(/, */) last = parts.shift first = parts.reverse.join(' ') {first: first, last: last} end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gutenberg_rdf-0.2.1 | lib/gutenberg_rdf/rdf/agent.rb |
gutenberg_rdf-0.1.0 | lib/gutenberg_rdf/rdf/agent.rb |