Class: Wikidatum::DataType::GlobeCoordinate
- Inherits:
-
Object
- Object
- Wikidatum::DataType::GlobeCoordinate
- Defined in:
- lib/wikidatum/data_type/globe_coordinate.rb
Overview
The Globe Coordinate type JSON looks like this:
{
"property": {
"id": "P740",
"data-type": "globe-coordinate"
},
"value": {
"type": "value",
"content": {
"latitude": 38.8977,
"longitude": -77.0365,
"precision": 0.0001,
"globe": "http://www.wikidata.org/entity/Q2"
}
}
}
Defined Under Namespace
Classes: HumanizedStruct
Instance Attribute Summary collapse
-
#globe ⇒ String
readonly
A URL (usually in the same Wikibase instance) representing the given globe model (e.g. Earth).
- #latitude ⇒ Float readonly
- #longitude ⇒ Float readonly
- #precision ⇒ Float readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#humanized ⇒ HumanizedStruct<latitude, longitude, precision, globe>
The content of the data value object.
- #initialize(latitude:, longitude:, precision:, globe:) ⇒ void constructor
- #to_h ⇒ Hash
-
#wikibase_type ⇒ String
The “type” value used by Wikibase, for use when creating/updating statements.
Constructor Details
#initialize(latitude:, longitude:, precision:, globe:) ⇒ void
42 43 44 45 46 47 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 42 def initialize(latitude:, longitude:, precision:, globe:) @latitude = latitude @longitude = longitude @precision = precision @globe = globe end |
Instance Attribute Details
#globe ⇒ String (readonly)
Returns A URL (usually in the same Wikibase instance) representing the given globe model (e.g. Earth).
35 36 37 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 35 def globe @globe end |
#latitude ⇒ Float (readonly)
26 27 28 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 26 def latitude @latitude end |
#longitude ⇒ Float (readonly)
29 30 31 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 29 def longitude @longitude end |
#precision ⇒ Float (readonly)
32 33 34 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 32 def precision @precision end |
Class Method Details
.symbolized_name ⇒ Symbol
77 78 79 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 77 def self.symbolized_name :globe_coordinate end |
Instance Method Details
#humanized ⇒ HumanizedStruct<latitude, longitude, precision, globe>
The content of the data value object. Use this to get a more sensible representation of the statement’s contents.
72 73 74 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 72 def humanized HumanizedStruct.new(to_h) end |
#to_h ⇒ Hash
50 51 52 53 54 55 56 57 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 50 def to_h { latitude: @latitude, longitude: @longitude, precision: @precision, globe: @globe } end |
#wikibase_type ⇒ String
The “type” value used by Wikibase, for use when creating/updating statements.
62 63 64 |
# File 'lib/wikidatum/data_type/globe_coordinate.rb', line 62 def wikibase_type 'globe-coordinate' end |