Class: BibCard::Person
- Inherits:
-
Spira::Base
- Object
- Spira::Base
- BibCard::Person
- Defined in:
- lib/bib_card/person.rb
Instance Method Summary collapse
- #dbpedia_resource ⇒ Object
- #dbpedia_uri ⇒ Object
- #getty_subject ⇒ Object
- #getty_uri ⇒ Object
- #loc_uri ⇒ Object
- #name(preferred_languages = nil) ⇒ Object
- #uri ⇒ Object
- #wikidata_entity ⇒ Object
- #wikidata_uri ⇒ Object
Instance Method Details
#dbpedia_resource ⇒ Object
46 47 48 |
# File 'lib/bib_card/person.rb', line 46 def dbpedia_resource self.dbpedia_uri.as(BibCard::DBPedia::Resource) if self.dbpedia_uri end |
#dbpedia_uri ⇒ Object
30 31 32 33 |
# File 'lib/bib_card/person.rb', line 30 def dbpedia_uri stmt = ("http://dbpedia.org/resource") stmt.nil? ? nil : stmt.object end |
#getty_subject ⇒ Object
50 51 52 |
# File 'lib/bib_card/person.rb', line 50 def getty_subject self.getty_uri.as(BibCard::Getty::Subject) if self.getty_uri end |
#getty_uri ⇒ Object
35 36 37 38 39 |
# File 'lib/bib_card/person.rb', line 35 def getty_uri stmt = ("http://vocab.getty.edu/ulan") # Note that we are modifying the URI to get the RWO URI stmt.nil? ? nil : RDF::URI.new( stmt.object.to_s.gsub('-agent', '') ) end |
#loc_uri ⇒ Object
25 26 27 28 |
# File 'lib/bib_card/person.rb', line 25 def loc_uri stmt = ("http://id.loc.gov/authorities/names/") stmt.nil? ? nil : stmt.object end |
#name(preferred_languages = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bib_card/person.rb', line 12 def name(preferred_languages = nil) if preferred_languages matches = Spira.repository.query({subject: @subject, predicate: SCHEMA_NAME}).reduce(Array.new) do |matches, stmt| language = stmt.object.language.to_s matches << stmt if preferred_languages.include?(language) matches end else matches = Spira.repository.query({subject: @subject, predicate: SCHEMA_NAME}) end matches.first.nil? ? nil : matches.first.object.to_s end |
#uri ⇒ Object
8 9 10 |
# File 'lib/bib_card/person.rb', line 8 def uri self.subject end |
#wikidata_entity ⇒ Object
54 55 56 |
# File 'lib/bib_card/person.rb', line 54 def wikidata_entity self.wikidata_uri.as(BibCard::Wikidata::Entity) if self.wikidata_uri end |
#wikidata_uri ⇒ Object
41 42 43 44 |
# File 'lib/bib_card/person.rb', line 41 def wikidata_uri stmt = ("http://www.wikidata.org/entity") stmt.nil? ? nil : stmt.object end |