Class: Everypolitician::Popolo::Entity
- Inherits:
-
Object
- Object
- Everypolitician::Popolo::Entity
- Defined in:
- lib/everypolitician/popolo/entity.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](key) ⇒ Object
-
#initialize(document) ⇒ Entity
constructor
A new instance of Entity.
- #key?(key) ⇒ Boolean
Constructor Details
#initialize(document) ⇒ Entity
Returns a new instance of Entity.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/everypolitician/popolo/entity.rb', line 8 def initialize(document) @document = document document.each do |key, value| if respond_to?("#{key}=") __send__("#{key}=", value) else define_singleton_method(key) { value } end end end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
6 7 8 |
# File 'lib/everypolitician/popolo/entity.rb', line 6 def document @document end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/everypolitician/popolo/entity.rb', line 5 def id @id end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
28 29 30 |
# File 'lib/everypolitician/popolo/entity.rb', line 28 def ==(other) id == other.id end |
#[](key) ⇒ Object
20 21 22 |
# File 'lib/everypolitician/popolo/entity.rb', line 20 def [](key) document[key] end |
#key?(key) ⇒ Boolean
24 25 26 |
# File 'lib/everypolitician/popolo/entity.rb', line 24 def key?(key) document.key?(key) end |