Class: Contrek::Concurrent::InnerPolyline

Inherits:
Object
  • Object
show all
Defined in:
lib/contrek/finder/concurrent/inner_polyline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shape: nil, raw_coordinates: [], sequence: nil) ⇒ InnerPolyline

Returns a new instance of InnerPolyline.



9
10
11
12
13
14
15
16
17
# File 'lib/contrek/finder/concurrent/inner_polyline.rb', line 9

def initialize(shape: nil, raw_coordinates: [], sequence: nil)
  if sequence
    @shape = sequence.shape
    @raw = sequence.to_a
  else
    @shape = shape
    @raw = raw_coordinates
  end
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/contrek/finder/concurrent/inner_polyline.rb', line 6

def raw
  @raw
end

#shapeObject

Returns the value of attribute shape.



7
8
9
# File 'lib/contrek/finder/concurrent/inner_polyline.rb', line 7

def shape
  @shape
end

#vertical_boundsObject (readonly)

Returns the value of attribute vertical_bounds.



6
7
8
# File 'lib/contrek/finder/concurrent/inner_polyline.rb', line 6

def vertical_bounds
  @vertical_bounds
end

Instance Method Details

#compute_vertical_bounds!Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/contrek/finder/concurrent/inner_polyline.rb', line 19

def compute_vertical_bounds!
  @vertical_bounds ||= begin
    min_y = Float::INFINITY
    max_y = 0
    @raw.each do |pos|
      y = pos[:y]
      min_y = y if y < min_y
      max_y = y if y > max_y
    end
    {min: min_y, max: max_y}
  end
end