Module: Draught::Pathlike
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](index_start_or_range, length = nil) ⇒ Object
- #approximates?(other, delta) ⇒ Boolean
- #box_type ⇒ Object
- #containers ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
- #last ⇒ Object
- #number_of_points ⇒ Object
- #paths ⇒ Object
- #points ⇒ Object
- #transform(transformation) ⇒ Object
- #translate(vector) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
35 36 37 38 |
# File 'lib/draught/pathlike.rb', line 35 def ==(other) return false if number_of_points != other.number_of_points points.zip(other.points).all? { |a, b| a == b } end |
#[](index_start_or_range, length = nil) ⇒ Object
15 16 17 |
# File 'lib/draught/pathlike.rb', line 15 def [](index_start_or_range, length = nil) raise NotImplementedError, "Pathlike objects must implement [] access on their points, returning a new instance" end |
#approximates?(other, delta) ⇒ Boolean
40 41 42 43 |
# File 'lib/draught/pathlike.rb', line 40 def approximates?(other, delta) return false if number_of_points != other.number_of_points points.zip(other.points).all? { |a, b| a.approximates?(b, delta) } end |
#box_type ⇒ Object
53 54 55 |
# File 'lib/draught/pathlike.rb', line 53 def box_type [:path] end |
#containers ⇒ Object
49 50 51 |
# File 'lib/draught/pathlike.rb', line 49 def containers [] end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/draught/pathlike.rb', line 31 def empty? points.empty? end |
#first ⇒ Object
23 24 25 |
# File 'lib/draught/pathlike.rb', line 23 def first points.first end |
#last ⇒ Object
27 28 29 |
# File 'lib/draught/pathlike.rb', line 27 def last points.last end |
#number_of_points ⇒ Object
19 20 21 |
# File 'lib/draught/pathlike.rb', line 19 def number_of_points points.length end |
#paths ⇒ Object
45 46 47 |
# File 'lib/draught/pathlike.rb', line 45 def paths [] end |
#points ⇒ Object
3 4 5 |
# File 'lib/draught/pathlike.rb', line 3 def points raise NotImplementedError, "Pathlike objects must return an array of their points" end |
#transform(transformation) ⇒ Object
11 12 13 |
# File 'lib/draught/pathlike.rb', line 11 def transform(transformation) raise NotImplementedError, "Pathlike objects must implement transformation by Affine transform or point-taking lambda" end |
#translate(vector) ⇒ Object
7 8 9 |
# File 'lib/draught/pathlike.rb', line 7 def translate(vector) raise NotImplementedError, "Pathlike objects must implement translation by Vector" end |