Class: Unit::Types::Coordinates
- Inherits:
-
Object
- Object
- Unit::Types::Coordinates
- Defined in:
- lib/unit-ruby/types/coordinates.rb
Instance Attribute Summary collapse
-
#latitude ⇒ Object
readonly
Returns the value of attribute latitude.
-
#longitude ⇒ Object
readonly
Returns the value of attribute longitude.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json_api ⇒ Object
-
#initialize(longitude:, latitude:) ⇒ Coordinates
constructor
A new instance of Coordinates.
Constructor Details
#initialize(longitude:, latitude:) ⇒ Coordinates
Returns a new instance of Coordinates.
6 7 8 9 |
# File 'lib/unit-ruby/types/coordinates.rb', line 6 def initialize(longitude:, latitude:) @longitude = longitude @latitude = latitude end |
Instance Attribute Details
#latitude ⇒ Object (readonly)
Returns the value of attribute latitude.
4 5 6 |
# File 'lib/unit-ruby/types/coordinates.rb', line 4 def latitude @latitude end |
#longitude ⇒ Object (readonly)
Returns the value of attribute longitude.
4 5 6 |
# File 'lib/unit-ruby/types/coordinates.rb', line 4 def longitude @longitude end |
Class Method Details
.cast(val) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/unit-ruby/types/coordinates.rb', line 11 def self.cast(val) return val if val.is_a? self return nil if val.nil? new(longitude: val[:longitude], latitude: val[:latitude]) end |
Instance Method Details
#as_json_api ⇒ Object
18 19 20 |
# File 'lib/unit-ruby/types/coordinates.rb', line 18 def as_json_api { longitude: longitude, latitude: latitude } end |