Class: ServerSideGoogleMaps::Segment
- Inherits:
-
Object
- Object
- ServerSideGoogleMaps::Segment
- Defined in:
- lib/server-side-google-maps/segment.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
Instance Method Summary collapse
- #dlat ⇒ Object
- #dlon ⇒ Object
-
#initialize(point1, point2) ⇒ Segment
constructor
A new instance of Segment.
- #length2 ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(point1, point2) ⇒ Segment
Returns a new instance of Segment.
5 6 7 8 |
# File 'lib/server-side-google-maps/segment.rb', line 5 def initialize(point1, point2) @first = point1 @last = point2 end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
3 4 5 |
# File 'lib/server-side-google-maps/segment.rb', line 3 def first @first end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
3 4 5 |
# File 'lib/server-side-google-maps/segment.rb', line 3 def last @last end |
Instance Method Details
#dlat ⇒ Object
10 11 12 |
# File 'lib/server-side-google-maps/segment.rb', line 10 def dlat @dlat ||= last.latitude - first.latitude end |
#dlon ⇒ Object
14 15 16 |
# File 'lib/server-side-google-maps/segment.rb', line 14 def dlon @dlon ||= last.longitude - first.longitude end |
#length2 ⇒ Object
18 19 20 |
# File 'lib/server-side-google-maps/segment.rb', line 18 def length2 @length2 ||= dlat * dlat + dlon * dlon end |
#to_a ⇒ Object
22 23 24 |
# File 'lib/server-side-google-maps/segment.rb', line 22 def to_a [first, last] end |