Class: Wikidatum::DataType::MonolingualText
- Inherits:
-
Object
- Object
- Wikidatum::DataType::MonolingualText
- Defined in:
- lib/wikidatum/data_type/monolingual_text.rb
Overview
The Monolingual Text type JSON looks like this:
{
"property": {
"id": "P13432",
"data-type": "monolingualtext"
},
"value": {
"type": "value",
"content": {
"text": "foo",
"language": "en-gb"
}
}
}
Defined Under Namespace
Classes: HumanizedStruct
Instance Attribute Summary collapse
-
#language ⇒ String
readonly
The language code, e.g.
- #text ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#humanized ⇒ HumanizedStruct<language, text>
The content of the data value object.
- #initialize(language:, text:) ⇒ void constructor
- #to_h ⇒ Hash
-
#wikibase_type ⇒ String
The “type” value used by Wikibase, for use when creating/updating statements.
Constructor Details
#initialize(language:, text:) ⇒ void
32 33 34 35 |
# File 'lib/wikidatum/data_type/monolingual_text.rb', line 32 def initialize(language:, text:) @language = language @text = text end |
Instance Attribute Details
#language ⇒ String (readonly)
Returns the language code, e.g. ‘en’.
24 25 26 |
# File 'lib/wikidatum/data_type/monolingual_text.rb', line 24 def language @language end |
#text ⇒ String (readonly)
27 28 29 |
# File 'lib/wikidatum/data_type/monolingual_text.rb', line 27 def text @text end |
Class Method Details
.symbolized_name ⇒ Symbol
63 64 65 |
# File 'lib/wikidatum/data_type/monolingual_text.rb', line 63 def self.symbolized_name :monolingual_text end |
Instance Method Details
#humanized ⇒ HumanizedStruct<language, text>
The content of the data value object. Use this to get a more sensible representation of the statement’s contents.
58 59 60 |
# File 'lib/wikidatum/data_type/monolingual_text.rb', line 58 def humanized HumanizedStruct.new(to_h) end |
#to_h ⇒ Hash
38 39 40 41 42 43 |
# File 'lib/wikidatum/data_type/monolingual_text.rb', line 38 def to_h { language: @language, text: @text } end |
#wikibase_type ⇒ String
The “type” value used by Wikibase, for use when creating/updating statements.
48 49 50 |
# File 'lib/wikidatum/data_type/monolingual_text.rb', line 48 def wikibase_type 'monolingualtext' end |