Class: Geospatial::Point

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#coordinatesObject (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

#objectObject (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

Returns:

  • (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

#hashObject



54
55
56
# File 'lib/geospatial/map.rb', line 54

def hash
	@hash ||= @map.hash_for_coordinates(@coordinates).freeze
end