Class: BibCard::Person

Inherits:
Spira::Base
  • Object
show all
Defined in:
lib/bib_card/person.rb

Instance Method Summary collapse

Instance Method Details

#dbpedia_resourceObject



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_uriObject



30
31
32
33
# File 'lib/bib_card/person.rb', line 30

def dbpedia_uri
  stmt = related_entity_by_uri_prefix("http://dbpedia.org/resource")
  stmt.nil? ? nil : stmt.object
end

#getty_subjectObject



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_uriObject



35
36
37
38
39
# File 'lib/bib_card/person.rb', line 35

def getty_uri
  stmt = related_entity_by_uri_prefix("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_uriObject



25
26
27
28
# File 'lib/bib_card/person.rb', line 25

def loc_uri
  stmt = related_entity_by_uri_prefix("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

#uriObject



8
9
10
# File 'lib/bib_card/person.rb', line 8

def uri
  self.subject
end

#wikidata_entityObject



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_uriObject



41
42
43
44
# File 'lib/bib_card/person.rb', line 41

def wikidata_uri
  stmt = related_entity_by_uri_prefix("http://www.wikidata.org/entity")
  stmt.nil? ? nil : stmt.object
end