Class: Wikidata::Snak
- Inherits:
-
HashedObject
- Object
- HashedObject
- Wikidata::Snak
- Defined in:
- lib/wikidata/snak.rb
Instance Attribute Summary
Attributes inherited from HashedObject
Instance Method Summary collapse
Methods inherited from HashedObject
Constructor Details
This class inherits a constructor from Wikidata::HashedObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Wikidata::HashedObject
Instance Method Details
#inspect ⇒ Object
32 33 34 |
# File 'lib/wikidata/snak.rb', line 32 def inspect "<#{self.class.to_s} type=#{snaktype} property_id=#{property_id}>" end |
#property ⇒ Object
8 9 10 |
# File 'lib/wikidata/snak.rb', line 8 def property @property ||= Wikidata::Property.find_by_id(property_id) end |
#property_id ⇒ Object
4 5 6 |
# File 'lib/wikidata/snak.rb', line 4 def property_id data_hash.property end |
#value ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wikidata/snak.rb', line 12 def value @value ||= begin if datavalue['type'] == "wikibase-entityid" Wikidata::DataValues::Entity.new(datavalue.value) elsif datavalue['type'] == "time" Wikidata::DataValues::Time.new(datavalue.value) elsif datavalue['type'] == "globecoordinate" Wikidata::DataValues::Globecoordinate.new(datavalue.value) elsif datavalue['type'] == 'string' if property_id == "P18" || (@property && @property.datatype == "commonsMedia") Wikidata::DataValues::CommonsMedia.new({imagename: datavalue.value}) else Wikidata::DataValues::String.new({string: datavalue.value}) end else datavalue end end end |