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.



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

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

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

Returns:

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

#hashObject



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

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