Class: SurrealDB::GeometryLine
- Inherits:
-
Object
- Object
- SurrealDB::GeometryLine
- Defined in:
- lib/surrealdb/models/geometry.rb
Instance Attribute Summary collapse
- #points ⇒ Array<GeometryPoint> readonly
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #coordinates ⇒ Object
- #hash ⇒ Object
-
#initialize(*points) ⇒ GeometryLine
constructor
A new instance of GeometryLine.
- #inspect ⇒ Object
Constructor Details
#initialize(*points) ⇒ GeometryLine
Returns a new instance of GeometryLine.
34 35 36 37 38 |
# File 'lib/surrealdb/models/geometry.rb', line 34 def initialize(*points) raise ArgumentError, 'a line requires at least 2 points' if points.length < 2 @points = points.freeze end |
Instance Attribute Details
#points ⇒ Array<GeometryPoint> (readonly)
32 33 34 |
# File 'lib/surrealdb/models/geometry.rb', line 32 def points @points end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
44 45 46 |
# File 'lib/surrealdb/models/geometry.rb', line 44 def ==(other) other.is_a?(GeometryLine) && other.points == @points end |
#coordinates ⇒ Object
40 41 42 |
# File 'lib/surrealdb/models/geometry.rb', line 40 def coordinates @points.map(&:coordinates) end |
#hash ⇒ Object
49 50 51 |
# File 'lib/surrealdb/models/geometry.rb', line 49 def hash [self.class, @points].hash end |
#inspect ⇒ Object
53 54 55 |
# File 'lib/surrealdb/models/geometry.rb', line 53 def inspect "GeometryLine(#{@points.length} points)" end |