Sha256: 7611067d84bff2df9c1a81944dc7760f9de1dc114220abf292d9911c547f4765

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module BibCard
  module DBPedia
    class Resource < Spira::Base

      configure base_uri: "http://dbpedia.org/resource/"

      property :given_name, predicate: FOAF_GIVEN_NAME, type: XSD.string
      property :surname, predicate: FOAF_SURNAME, type: XSD.string
      property :rdfs_label, predicate: RDF::RDFS.label, type: XSD.string
      property :abstract, predicate: BibCard::DBO_ABSTRACT, type: XSD.string
      property :founded, predicate: DBP_FOUNDED, type: XSD.string
      property :location, predicate: DBP_LOCATION, type: XSD.string
      property :thumbnail, predicate: DBO_THUMBNAIL, type: RDF::URI
      property :depiction, predicate: FOAF_DEPICTION, type: RDF::URI
      has_many :influences, predicate: DBO_INFLUENCED_BY, type: 'DBPedia::Resource'
      has_many :influencees, predicate: DBO_INFLUENCED, type: 'DBPedia::Resource'

      def name
        if self.given_name and self.surname
          self.given_name + ' ' + self.surname
        else
          self.rdfs_label
        end
      end

      def film_appearances
        Spira.repository.query({predicate: DBO_STARRING, object: self.subject}).map do |film|
          film.subject.as(DBPedia::Resource)
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bib_card-0.6.2 lib/bib_card/db_pedia/resource.rb
bib_card-0.6.1 lib/bib_card/db_pedia/resource.rb
bib_card-0.5.0 lib/bib_card/db_pedia/resource.rb