class Everypolitician::Popolo::Entity
Attributes
document[R]
popolo[R]
Public Class Methods
classification(classification = nil)
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 9 def self.classification(classification = nil) @classification ||= classification end
inherited(subclass)
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 13 def self.inherited(subclass) @subclasses ||= [] @subclasses.push(subclass) end
new(document, popolo = nil)
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 22 def initialize(document, popolo = nil) @document = document @popolo = popolo document.each do |key, value| if respond_to?("#{key}=") __send__("#{key}=", value) else define_singleton_method(key) { value } end end end
subclasses()
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 18 def self.subclasses @subclasses || [] end
Public Instance Methods
==(other)
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 47 def ==(other) self.class == other.class && id == other.id end
Also aliased as: eql?
[](key)
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 39 def [](key) document[key] end
id()
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 35 def id document.fetch(:id, nil) end
identifier(scheme)
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 56 def identifier(scheme) identifiers.find(-> { {} }) { |i| i[:scheme] == scheme }[:identifier] end
identifiers()
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 52 def identifiers document.fetch(:identifiers, []) end
key?(key)
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 43 def key?(key) document.key?(key) end
wikidata()
click to toggle source
# File lib/everypolitician/popolo/entity.rb, line 60 def wikidata identifier('wikidata') end