Class: CartoJson::LineString
- Inherits:
-
Object
- Object
- CartoJson::LineString
- Includes:
- Shape
- Defined in:
- lib/carto_json/line_string.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#points ⇒ Object
Returns the value of attribute points.
Instance Method Summary collapse
-
#initialize(input) ⇒ LineString
constructor
A new instance of LineString.
- #to_hash ⇒ Object
- #to_wkt ⇒ Object
Methods included from Shape
included, #to_json, #to_pretty_json, #to_s, #type
Constructor Details
#initialize(input) ⇒ LineString
Returns a new instance of LineString.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/carto_json/line_string.rb', line 8 def initialize(input) super @points = [] input[:points].each do |p| if p.is_a?(Point) @points << p else @points << Point.new(LAT => p[LAT], LNG => p[LNG]) end end validate end |
Instance Attribute Details
#points ⇒ Object
Returns the value of attribute points.
6 7 8 |
# File 'lib/carto_json/line_string.rb', line 6 def points @points end |
Instance Method Details
#to_hash ⇒ Object
22 23 24 25 |
# File 'lib/carto_json/line_string.rb', line 22 def to_hash {:type => self.class.type, :points => points.collect {|p| p.to_hash_for_array}} end |