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.
30 31 32 33 34 |
# File 'lib/geospatial/map.rb', line 30 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.
46 47 48 |
# File 'lib/geospatial/map.rb', line 46 def coordinates @coordinates end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
36 37 38 |
# File 'lib/geospatial/map.rb', line 36 def object @object end |
Instance Method Details
#[](index) ⇒ Object
38 39 40 |
# File 'lib/geospatial/map.rb', line 38 def [] index @coordinates[index] end |
#[]=(index, value) ⇒ Object
42 43 44 |
# File 'lib/geospatial/map.rb', line 42 def []= index, value @coordinates[index] = value end |
#eql?(other) ⇒ Boolean
50 51 52 |
# File 'lib/geospatial/map.rb', line 50 def eql?(other) self.class.eql?(other.class) and @coordinates.eql?(other.coordinates) end |
#hash ⇒ Object
54 55 56 |
# File 'lib/geospatial/map.rb', line 54 def hash @hash ||= @map.hash_for_coordinates(@coordinates).freeze end |