Class: NSWTopo::Labels::Fence
- Inherits:
-
Object
- Object
- NSWTopo::Labels::Fence
- Defined in:
- lib/nswtopo/layer/labels/fence.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #bounds ⇒ Object
- #conflicts_with?(segment, buffer = 0) ⇒ Boolean
-
#initialize(segment, buffer: 0, index:) ⇒ Fence
constructor
A new instance of Fence.
Constructor Details
#initialize(segment, buffer: 0, index:) ⇒ Fence
Returns a new instance of Fence.
4 5 6 |
# File 'lib/nswtopo/layer/labels/fence.rb', line 4 def initialize(segment, buffer: 0, index:) @segment, @buffer, @index = segment, buffer, index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
7 8 9 |
# File 'lib/nswtopo/layer/labels/fence.rb', line 7 def index @index end |
Instance Method Details
#bounds ⇒ Object
9 10 11 12 13 |
# File 'lib/nswtopo/layer/labels/fence.rb', line 9 def bounds @segment.transpose.map(&:minmax).map do |min, max| [min - @buffer, max + @buffer] end end |
#conflicts_with?(segment, buffer = 0) ⇒ Boolean
15 16 17 |
# File 'lib/nswtopo/layer/labels/fence.rb', line 15 def conflicts_with?(segment, buffer = 0) [@segment, segment].overlap?(@buffer + buffer) end |