Class: Sevgi::Sundries::Grid
Overview
Builds a tile-like grid from horizontal and vertical rulers.
Defined Under Namespace
Instance Attribute Summary collapse
-
#x ⇒ Sevgi::Sundries::Grid::X
readonly
Returns the horizontal axis ruler and line queries.
-
#y ⇒ Sevgi::Sundries::Grid::Y
readonly
Returns the vertical axis ruler and line queries.
Attributes inherited from Tile
Class Method Summary collapse
-
.[](x, y) ⇒ Sevgi::Sundries::Grid
Builds a grid using bracket syntax.
Instance Method Summary collapse
-
#canvas ⇒ Sevgi::Graphics::Canvas
Returns a graphics canvas matching the rulers and computed margins.
-
#height ⇒ Float
Returns the fitted grid height.
-
#initialize(x:, y:) ⇒ void
constructor
Creates a grid from horizontal and vertical rulers.
-
#width ⇒ Float
Returns the fitted grid width.
Methods inherited from Tile
#[], #box, #cell, #col, #colbox, #cols, #each, #each_col, #row, #rowbox, #rows
Constructor Details
#initialize(x:, y:) ⇒ void
Creates a grid from horizontal and vertical rulers.
29 30 31 32 33 34 35 36 |
# File 'lib/sevgi/sundries/grid.rb', line 29 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 ⇒ Sevgi::Sundries::Grid::X (readonly)
Returns the horizontal axis ruler and line queries.
18 19 20 |
# File 'lib/sevgi/sundries/grid.rb', line 18 def x @x end |
#y ⇒ Sevgi::Sundries::Grid::Y (readonly)
Returns the vertical axis ruler and line queries.
22 23 24 |
# File 'lib/sevgi/sundries/grid.rb', line 22 def y @y end |
Class Method Details
.[](x, y) ⇒ Sevgi::Sundries::Grid
Builds a grid using bracket syntax.
14 |
# File 'lib/sevgi/sundries/grid.rb', line 14 def self.[](x, y) = new(x:, y:) |
Instance Method Details
#canvas ⇒ Sevgi::Graphics::Canvas
Returns a graphics canvas matching the rulers and computed margins.
40 41 42 43 44 45 |
# File 'lib/sevgi/sundries/grid.rb', line 40 def canvas Graphics::Canvas.new( **Graphics::Paper[x.brut, y.brut].to_h, margins: Graphics::Margin[y.margin, x.margin].to_a ) end |
#height ⇒ Float
Returns the fitted grid height.
49 |
# File 'lib/sevgi/sundries/grid.rb', line 49 def height = y.d |
#width ⇒ Float
Returns the fitted grid width.
53 |
# File 'lib/sevgi/sundries/grid.rb', line 53 def width = x.d |