Class: Sevgi::Sundries::Grid
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
Constructor Details
#initialize(x:, y:) ⇒ Grid
Returns a new instance of Grid.
12 13 14 15 16 17 18 19 |
# File 'lib/sevgi/sundries/grid.rb', line 12 def initialize(x:, y:) ArgumentError.("Arguments must be Ruler objects") unless [x, y].all?(Ruler) @x = X.new(x, y) @y = Y.new(x, y) super(Geometry::Rect[@x.u, @y.u], nx: @x.n, ny: @y.n) end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
10 11 12 |
# File 'lib/sevgi/sundries/grid.rb', line 10 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
10 11 12 |
# File 'lib/sevgi/sundries/grid.rb', line 10 def y @y end |
Class Method Details
.[](x, y) ⇒ Object
8 |
# File 'lib/sevgi/sundries/grid.rb', line 8 def self.[](x, y) = new(x:, y:) |
Instance Method Details
#canvas ⇒ Object
21 22 23 24 25 26 |
# File 'lib/sevgi/sundries/grid.rb', line 21 def canvas Graphics::Canvas.new( **Graphics::Paper[x.brut, y.brut].to_h, margins: Graphics::Margin[y.margin, x.margin].to_a ) end |
#height ⇒ Object
28 |
# File 'lib/sevgi/sundries/grid.rb', line 28 def height = y.d |
#width ⇒ Object
30 |
# File 'lib/sevgi/sundries/grid.rb', line 30 def width = x.d |