Class: Wikidatum::DataType::Base
- Inherits:
-
Object
- Object
- Wikidatum::DataType::Base
- Defined in:
- lib/wikidatum/data_type/base.rb
Instance Attribute Summary collapse
-
#content ⇒ DataType::GlobeCoordinate, ...
readonly
The value of the “content” attribute in the response.
-
#type ⇒ Symbol
readonly
Represents the type for this instance.
Instance Method Summary collapse
-
#humanized_content ⇒ String, ...
Get the humanized version of the content.
- #initialize(type:, content:) ⇒ void constructor
- #to_h ⇒ Hash
Constructor Details
#initialize(type:, content:) ⇒ void
37 38 39 40 |
# File 'lib/wikidatum/data_type/base.rb', line 37 def initialize(type:, content:) @type = type @content = content end |
Instance Attribute Details
#content ⇒ DataType::GlobeCoordinate, ... (readonly)
The value of the “content” attribute in the response.
If the ‘type` is `novalue` or `somevalue`, this returns `nil`.
32 33 34 |
# File 'lib/wikidatum/data_type/base.rb', line 32 def content @content end |
#type ⇒ Symbol (readonly)
Represents the type for this instance.
Possible values for the ‘type` attribute are:
-
‘:no_value`: No value
-
‘:some_value`: Unknown value
-
‘:commons_media`: CommonsMedia
-
‘:external_id`: ExternalId
-
‘:globe_coordinate`: GlobeCoordinate
-
‘:monolingual_text`: MonolingualText
-
‘:quantity`: Quantity
-
‘:string`: WikibaseString
-
‘:time`: Time
-
‘:url`: WikibaseUrl
-
‘:wikibase_item`: WikibaseItem
25 26 27 |
# File 'lib/wikidatum/data_type/base.rb', line 25 def type @type end |
Instance Method Details
#humanized_content ⇒ String, ...
Get the humanized version of the content. Depending on the given data type, it will return values in different formats.
54 55 56 |
# File 'lib/wikidatum/data_type/base.rb', line 54 def humanized_content @content.humanized end |
#to_h ⇒ Hash
43 44 45 46 47 48 |
# File 'lib/wikidatum/data_type/base.rb', line 43 def to_h { type: @type, content: @content&.to_h } end |