Class: Geospatial::Point
- Inherits:
-
Object
- Object
- Geospatial::Point
- Defined in:
- lib/geospatial/map.rb
Overview
A point is a location on a map with a specific hash representation based on the map. A point might store multi-dimentional data (e.g. longitude, latitude, time) which is hashed to a single column.
Instance Attribute Summary collapse
-
#coordinates ⇒ Object
(also: #to_a)
readonly
Returns the value of attribute coordinates.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #[]=(index, value) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(map, coordinates, object = nil) ⇒ Point
constructor
A new instance of Point.
Constructor Details
#initialize(map, coordinates, object = nil) ⇒ Point
Returns a new instance of Point.
29 30 31 32 33 |
# File 'lib/geospatial/map.rb', line 29 def initialize(map, coordinates, object = nil) @map = map @coordinates = coordinates @object = object end |
Instance Attribute Details
#coordinates ⇒ Object (readonly) Also known as: to_a
Returns the value of attribute coordinates.
45 46 47 |
# File 'lib/geospatial/map.rb', line 45 def coordinates @coordinates end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
35 36 37 |
# File 'lib/geospatial/map.rb', line 35 def object @object end |
Instance Method Details
#[](index) ⇒ Object
37 38 39 |
# File 'lib/geospatial/map.rb', line 37 def [] index @coordinates[index] end |
#[]=(index, value) ⇒ Object
41 42 43 |
# File 'lib/geospatial/map.rb', line 41 def []= index, value @coordinates[index] = value end |
#eql?(other) ⇒ Boolean
49 50 51 |
# File 'lib/geospatial/map.rb', line 49 def eql?(other) self.class.eql?(other.class) and @coordinates.eql?(other.coordinates) end |
#hash ⇒ Object
53 54 55 |
# File 'lib/geospatial/map.rb', line 53 def hash @hash ||= @map.hash_for_coordinates(@coordinates).freeze end |