Sha256: bcf1ebf4918d8a624d7bcc18a3eee42e05c6b9ea49f9d6da2c13bce0c3722374
Contents?: true
Size: 1.3 KB
Versions: 7
Compression:
Stored size: 1.3 KB
Contents
require_relative '../face_parser' module GridGenerator module RexCube class Grid def initialize(x:, y:, units: , elements: ) @x, @y = x, y @units = units @elements = case elements when String FaceParser.new(elements).parse when Array elements else raise ArgumentError, "elements must be array or string" end end attr_reader :x, :y, :units, :elements def to_svg output = '' element_shapes.each { |element| output += element.to_svg if element } output end private def build_element(row_num, col_num, data) if data element_factory_class.new( grid_x: x, grid_y: y, row_num: row_num, col_num: col_num, units: units, colour: data[:colour], opacity: data[:opacity] ).build else nil end end def element_shapes elements.each_with_index.map do |row, row_num| row.each_with_index.map do |col, col_num| build_element(row_num, col_num, col) end end.flatten.compact end end end end
Version data entries
7 entries across 7 versions & 1 rubygems