Class: C4::Model::Column
- Inherits:
-
Object
- Object
- C4::Model::Column
- Defined in:
- lib/c4/model/column.rb
Instance Attribute Summary collapse
-
#max_size ⇒ Object
readonly
Returns the value of attribute max_size.
-
#stones ⇒ Object
readonly
Returns the value of attribute stones.
Instance Method Summary collapse
- #full? ⇒ Boolean
-
#initialize(max_size) ⇒ Column
constructor
A new instance of Column.
- #put!(mark) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(max_size) ⇒ Column
Returns a new instance of Column.
13 14 15 16 |
# File 'lib/c4/model/column.rb', line 13 def initialize(max_size) @stones = [] @max_size = max_size end |
Instance Attribute Details
#max_size ⇒ Object (readonly)
Returns the value of attribute max_size.
11 12 13 |
# File 'lib/c4/model/column.rb', line 11 def max_size @max_size end |
#stones ⇒ Object (readonly)
Returns the value of attribute stones.
11 12 13 |
# File 'lib/c4/model/column.rb', line 11 def stones @stones end |
Instance Method Details
#full? ⇒ Boolean
24 25 26 |
# File 'lib/c4/model/column.rb', line 24 def full? stones.size >= max_size end |
#put!(mark) ⇒ Object
18 19 20 21 22 |
# File 'lib/c4/model/column.rb', line 18 def put!(mark) raise ColumnFullError, 'This column is full!' if full? stones.push(mark) end |
#to_a ⇒ Object
28 29 30 |
# File 'lib/c4/model/column.rb', line 28 def to_a stones.fill_up_to(max_size, nil) end |