Class: Sevgi::Geometry::Grid
- Defined in:
- lib/sevgi/geometry/sundries/grid.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Attributes inherited from Tile
Class Method Summary collapse
Instance Method Summary collapse
- #canvas ⇒ Object
- #height ⇒ Object
-
#initialize(x:, y:) ⇒ Grid
constructor
A new instance of Grid.
- #width ⇒ Object
Methods inherited from Tile
#[], #box, #cell, #col, #colbox, #cols, #each, #each_col, #row, #rowbox, #rows
Methods inherited from Element
#at, #bh, #box, #bw, #ignorable?, #position, #position!, #translate
Constructor Details
#initialize(x:, y:) ⇒ Grid
Returns a new instance of Grid.
11 12 13 14 15 16 17 18 |
# File 'lib/sevgi/geometry/sundries/grid.rb', line 11 def initialize(x:, y:) ArgumentError.("Arguments must be Ruler objects") unless [ x, y ].all? { _1.is_a?(Ruler) } @x = X.new(x, y) @y = Y.new(x, y) super(Rect.new(width: @x.u, height: @y.u), nx: @x.n, ny: @y.n) end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
9 10 11 |
# File 'lib/sevgi/geometry/sundries/grid.rb', line 9 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
9 10 11 |
# File 'lib/sevgi/geometry/sundries/grid.rb', line 9 def y @y end |
Class Method Details
.[](x, y) ⇒ Object
75 |
# File 'lib/sevgi/geometry/sundries/grid.rb', line 75 def [](x, y) = new(x:, y:) |
Instance Method Details
#canvas ⇒ Object
20 |
# File 'lib/sevgi/geometry/sundries/grid.rb', line 20 def canvas = Graphics::Canvas.new(**Dim[x.brut, y.brut].to_h, margins: Margin[y.margin, x.margin].to_a) |
#height ⇒ Object
22 |
# File 'lib/sevgi/geometry/sundries/grid.rb', line 22 def height = y.d |
#width ⇒ Object
24 |
# File 'lib/sevgi/geometry/sundries/grid.rb', line 24 def width = x.d |