Class: WikibaseRepresentable::Model::Item
- Inherits:
-
Object
- Object
- WikibaseRepresentable::Model::Item
- Defined in:
- lib/wikibase_representable/model/item.rb
Overview
Represents a single Wikibase item. See www.mediawiki.org/wiki/Wikibase/DataModel#Items
Constant Summary collapse
- ENTITY_TYPE =
'item'
Instance Attribute Summary collapse
-
#alias_groups_hash ⇒ Object
Returns the value of attribute alias_groups_hash.
-
#descriptions_hash ⇒ Object
Returns the value of attribute descriptions_hash.
-
#id ⇒ Object
Returns the value of attribute id.
-
#labels_hash ⇒ Object
Returns the value of attribute labels_hash.
-
#site_links_hash ⇒ Object
Returns the value of attribute site_links_hash.
-
#statements_hash ⇒ Object
(also: #claims_hash)
Returns the value of attribute statements_hash.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #aliases_for_language(language_code) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(**kwargs) ⇒ Item
constructor
A new instance of Item.
- #label(language_code) ⇒ Object
- #link_to_site?(site_id) ⇒ Boolean
- #site_link(site_id) ⇒ Object
- #state ⇒ Object
- #statements_by_property_id(property_id) ⇒ Object (also: #claims_by_property_id)
- #statements_by_property_id?(property_id) ⇒ Boolean (also: #claims_by_property_id?)
Constructor Details
#initialize(**kwargs) ⇒ Item
Returns a new instance of Item.
18 19 20 21 22 23 24 25 26 |
# File 'lib/wikibase_representable/model/item.rb', line 18 def initialize(**kwargs) @type = ENTITY_TYPE @id = kwargs[:id] @labels_hash = kwargs[:labels_hash] || TermHash.new @descriptions_hash = kwargs[:descriptions_hash] || TermHash.new @alias_groups_hash = kwargs[:alias_groups_hash] || AliasGroupHash.new @site_links_hash = kwargs[:site_links_hash] || SiteLinkHash.new @statements_hash = kwargs[:statements_hash] || StatementHash.new end |
Instance Attribute Details
#alias_groups_hash ⇒ Object
Returns the value of attribute alias_groups_hash.
16 17 18 |
# File 'lib/wikibase_representable/model/item.rb', line 16 def alias_groups_hash @alias_groups_hash end |
#descriptions_hash ⇒ Object
Returns the value of attribute descriptions_hash.
16 17 18 |
# File 'lib/wikibase_representable/model/item.rb', line 16 def descriptions_hash @descriptions_hash end |
#id ⇒ Object
Returns the value of attribute id.
16 17 18 |
# File 'lib/wikibase_representable/model/item.rb', line 16 def id @id end |
#labels_hash ⇒ Object
Returns the value of attribute labels_hash.
16 17 18 |
# File 'lib/wikibase_representable/model/item.rb', line 16 def labels_hash @labels_hash end |
#site_links_hash ⇒ Object
Returns the value of attribute site_links_hash.
16 17 18 |
# File 'lib/wikibase_representable/model/item.rb', line 16 def site_links_hash @site_links_hash end |
#statements_hash ⇒ Object Also known as: claims_hash
Returns the value of attribute statements_hash.
16 17 18 |
# File 'lib/wikibase_representable/model/item.rb', line 16 def statements_hash @statements_hash end |
#type ⇒ Object
Returns the value of attribute type.
16 17 18 |
# File 'lib/wikibase_representable/model/item.rb', line 16 def type @type end |
Instance Method Details
#==(other) ⇒ Object
56 57 58 |
# File 'lib/wikibase_representable/model/item.rb', line 56 def ==(other) other.class == self.class && other.state == state end |
#aliases_for_language(language_code) ⇒ Object
32 33 34 |
# File 'lib/wikibase_representable/model/item.rb', line 32 def aliases_for_language(language_code) alias_groups_hash.aliases_for_language(language_code) end |
#eql?(other) ⇒ Boolean
60 61 62 |
# File 'lib/wikibase_representable/model/item.rb', line 60 def eql?(other) self == other end |
#label(language_code) ⇒ Object
28 29 30 |
# File 'lib/wikibase_representable/model/item.rb', line 28 def label(language_code) labels_hash.value_for_language(language_code) end |
#link_to_site?(site_id) ⇒ Boolean
48 49 50 |
# File 'lib/wikibase_representable/model/item.rb', line 48 def link_to_site?(site_id) site_links_hash.link_for_site?(site_id) end |
#site_link(site_id) ⇒ Object
44 45 46 |
# File 'lib/wikibase_representable/model/item.rb', line 44 def site_link(site_id) site_links_hash.link_for_site(site_id) end |
#state ⇒ Object
52 53 54 |
# File 'lib/wikibase_representable/model/item.rb', line 52 def state [type, id, labels_hash, descriptions_hash, alias_groups_hash, site_links_hash, statements_hash] end |
#statements_by_property_id(property_id) ⇒ Object Also known as: claims_by_property_id
36 37 38 |
# File 'lib/wikibase_representable/model/item.rb', line 36 def statements_by_property_id(property_id) statements_hash.statements_by_property_id(property_id) end |
#statements_by_property_id?(property_id) ⇒ Boolean Also known as: claims_by_property_id?
40 41 42 |
# File 'lib/wikibase_representable/model/item.rb', line 40 def statements_by_property_id?(property_id) statements_hash.statements_by_property_id?(property_id) end |