Class: Furud::ArrayValue
- Inherits:
-
Data
- Object
- Data
- Furud::ArrayValue
- Defined in:
- lib/furud/types.rb,
sig/furud.rbs
Instance Attribute Summary collapse
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #[](row, column) ⇒ Object
- #height ⇒ Integer
-
#initialize(rows:) ⇒ ArrayValue
constructor
A new instance of ArrayValue.
- #width ⇒ Integer
Constructor Details
#initialize(rows:) ⇒ ArrayValue
Returns a new instance of ArrayValue.
58 59 60 61 62 63 64 |
# File 'lib/furud/types.rb', line 58 def initialize(rows:) rows = rows.map { |row| row.dup.freeze }.freeze raise ArgumentError, "array must not be empty" if rows.empty? || rows.any?(&:empty?) raise ArgumentError, "array rows must have equal length" unless rows.map(&:length).uniq.one? super(rows: rows) end |
Instance Attribute Details
#rows ⇒ Object (readonly)
Returns the value of attribute rows
57 58 59 |
# File 'lib/furud/types.rb', line 57 def rows @rows end |
Instance Method Details
#[](row, column) ⇒ Object
68 |
# File 'lib/furud/types.rb', line 68 def [](row, column) = rows[row][column] |
#height ⇒ Integer
66 |
# File 'lib/furud/types.rb', line 66 def height = rows.length |
#width ⇒ Integer
67 |
# File 'lib/furud/types.rb', line 67 def width = rows.first.length |