Class: WikibaseRepresentable::Model::Statement
- Inherits:
-
Object
- Object
- WikibaseRepresentable::Model::Statement
- Includes:
- StatementDataValueHelper
- Defined in:
- lib/wikibase_representable/model/statement.rb
Overview
Class representing a Wikibase statement. See www.mediawiki.org/wiki/Wikibase/DataModel#Statements
Constant Summary collapse
- TYPE =
'statement'
- RANK_PREFERRED =
'preferred'
- RANK_NORMAL =
'normal'
- RANK_DEPRECATED =
'deprecated'
Instance Attribute Summary collapse
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#main_snak ⇒ Object
Returns the value of attribute main_snak.
-
#qualifiers ⇒ Object
Returns the value of attribute qualifiers.
-
#qualifiers_order ⇒ Object
Returns the value of attribute qualifiers_order.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(**kwargs) ⇒ Statement
constructor
A new instance of Statement.
- #property_id ⇒ Object
- #qualifiers_by_property_id(property_id) ⇒ Object
- #qualifiers_by_property_id?(property_id) ⇒ Boolean
- #state ⇒ Object
Methods included from StatementDataValueHelper
#data_value, #entity_id_value, #time_value, #value_type?
Constructor Details
#initialize(**kwargs) ⇒ Statement
Returns a new instance of Statement.
20 21 22 23 24 25 26 27 |
# File 'lib/wikibase_representable/model/statement.rb', line 20 def initialize(**kwargs) @main_snak = kwargs[:main_snak] @type = kwargs[:type] || TYPE @qualifiers = kwargs[:qualifiers] @qualifiers_order = kwargs[:qualifiers_order] @guid = kwargs[:guid] @rank = kwargs[:rank] || RANK_NORMAL end |
Instance Attribute Details
#guid ⇒ Object
Returns the value of attribute guid.
18 19 20 |
# File 'lib/wikibase_representable/model/statement.rb', line 18 def guid @guid end |
#main_snak ⇒ Object
Returns the value of attribute main_snak.
18 19 20 |
# File 'lib/wikibase_representable/model/statement.rb', line 18 def main_snak @main_snak end |
#qualifiers ⇒ Object
Returns the value of attribute qualifiers.
18 19 20 |
# File 'lib/wikibase_representable/model/statement.rb', line 18 def qualifiers @qualifiers end |
#qualifiers_order ⇒ Object
Returns the value of attribute qualifiers_order.
18 19 20 |
# File 'lib/wikibase_representable/model/statement.rb', line 18 def qualifiers_order @qualifiers_order end |
#rank ⇒ Object
Returns the value of attribute rank.
18 19 20 |
# File 'lib/wikibase_representable/model/statement.rb', line 18 def rank @rank end |
#type ⇒ Object
Returns the value of attribute type.
18 19 20 |
# File 'lib/wikibase_representable/model/statement.rb', line 18 def type @type end |
Instance Method Details
#==(other) ⇒ Object
45 46 47 |
# File 'lib/wikibase_representable/model/statement.rb', line 45 def ==(other) other.class == self.class && other.state == state end |
#eql?(other) ⇒ Boolean
49 50 51 |
# File 'lib/wikibase_representable/model/statement.rb', line 49 def eql?(other) self == other end |
#property_id ⇒ Object
37 38 39 |
# File 'lib/wikibase_representable/model/statement.rb', line 37 def property_id main_snak.property_id end |
#qualifiers_by_property_id(property_id) ⇒ Object
33 34 35 |
# File 'lib/wikibase_representable/model/statement.rb', line 33 def qualifiers_by_property_id(property_id) qualifiers&.snaks_by_property_id(property_id) end |
#qualifiers_by_property_id?(property_id) ⇒ Boolean
29 30 31 |
# File 'lib/wikibase_representable/model/statement.rb', line 29 def qualifiers_by_property_id?(property_id) qualifiers&.snaks_by_property_id?(property_id) end |
#state ⇒ Object
41 42 43 |
# File 'lib/wikibase_representable/model/statement.rb', line 41 def state [main_snak, type, qualifiers, qualifiers_order, guid, rank] end |