Class: Blackcal::SlotMatrix
- Inherits:
-
Object
- Object
- Blackcal::SlotMatrix
- Defined in:
- lib/blackcal/slot_matrix.rb
Overview
Slot matrix
Instance Method Summary collapse
-
#<<(value) ⇒ Object
Add value.
-
#data ⇒ Array<Array<Object>>
Data.
-
#initialize(slots) ⇒ SlotMatrix
constructor
Initialize slot matrix.
Constructor Details
#initialize(slots) ⇒ SlotMatrix
Initialize slot matrix
8 9 10 11 |
# File 'lib/blackcal/slot_matrix.rb', line 8 def initialize(slots) @matrix = [[]] @slots = slots end |
Instance Method Details
#<<(value) ⇒ Object
Add value
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/blackcal/slot_matrix.rb', line 20 def <<(value) array = @matrix[@matrix.length - 1] || [] # move to next slot when max slot length is reached if array.length >= @slots array = [] @matrix << array end array << value end |
#data ⇒ Array<Array<Object>>
Returns data.
14 15 16 |
# File 'lib/blackcal/slot_matrix.rb', line 14 def data @matrix end |