Class: CloudMade::Point

Inherits:
Geometry show all
Defined in:
lib/geometry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Geometry

parse

Constructor Details

#initialize(*args) ⇒ Point

Posible initializers are Point.new(1, -1) Point.new([1, -1])



41
42
43
44
45
46
47
48
49
# File 'lib/geometry.rb', line 41

def initialize(*args)
  if args.size == 1
    @lat = args[0][0]
    @lon = args[0][1]
  elsif args.size == 2
    @lat = args[0]
    @lon = args[1]
  end
end

Instance Attribute Details

#latObject

Returns the value of attribute lat.



35
36
37
# File 'lib/geometry.rb', line 35

def lat
  @lat
end

#lonObject

Returns the value of attribute lon.



36
37
38
# File 'lib/geometry.rb', line 36

def lon
  @lon
end

Instance Method Details

#==(point) ⇒ Object



51
52
53
# File 'lib/geometry.rb', line 51

def ==(point)
  return (point.lat == @lat and point.lon == @lon)
end

#to_latlonObject



59
60
61
# File 'lib/geometry.rb', line 59

def to_latlon
  "#{@lat},#{@lon}"
end

#to_sObject



55
56
57
# File 'lib/geometry.rb', line 55

def to_s
  "Point(#{@lat},#{@lon})"
end