Class: Furud::Area
- Inherits:
-
Data
- Object
- Data
- Furud::Area
- Defined in:
- lib/furud/types.rb,
sig/furud.rbs
Instance Attribute Summary collapse
-
#bottom ⇒ Object
readonly
Returns the value of attribute bottom.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#sheet ⇒ Object
readonly
Returns the value of attribute sheet.
-
#top ⇒ Object
readonly
Returns the value of attribute top.
Instance Method Summary collapse
- #include?(reference) ⇒ Boolean
-
#initialize(sheet: nil, top:, left:, bottom:, right:) ⇒ Area
constructor
A new instance of Area.
Constructor Details
#initialize(sheet: nil, top:, left:, bottom:, right:) ⇒ Area
Returns a new instance of Area.
14 15 16 17 18 19 20 21 |
# File 'lib/furud/types.rb', line 14 def initialize(sheet: nil, top:, left:, bottom:, right:) values = [top, left, bottom, right].map { |value| Integer(value) } raise ArgumentError, "area coordinates must be positive" unless values.all?(&:positive?) top, left, bottom, right = values super(sheet: sheet&.to_s, top: [top, bottom].min, left: [left, right].min, bottom: [top, bottom].max, right: [left, right].max) end |
Instance Attribute Details
#bottom ⇒ Object (readonly)
Returns the value of attribute bottom
13 14 15 |
# File 'lib/furud/types.rb', line 13 def bottom @bottom end |
#left ⇒ Object (readonly)
Returns the value of attribute left
13 14 15 |
# File 'lib/furud/types.rb', line 13 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right
13 14 15 |
# File 'lib/furud/types.rb', line 13 def right @right end |
#sheet ⇒ Object (readonly)
Returns the value of attribute sheet
13 14 15 |
# File 'lib/furud/types.rb', line 13 def sheet @sheet end |
#top ⇒ Object (readonly)
Returns the value of attribute top
13 14 15 |
# File 'lib/furud/types.rb', line 13 def top @top end |
Instance Method Details
#include?(reference) ⇒ Boolean
23 24 25 26 |
# File 'lib/furud/types.rb', line 23 def include?(reference) (sheet.nil? || reference.sheet == sheet) && reference.row.between?(top, bottom) && reference.column.between?(left, right) end |