Class: Stroop::Set
- Inherits:
-
Object
- Object
- Stroop::Set
- Defined in:
- lib/stroop/set.rb
Constant Summary collapse
- COLORS =
%w{ black white red green blue yellow }.freeze
- NEUTRAL =
:neutral
- CONGRUENT =
:congruent
- INCONGRUENT =
:incongruent
- MODES =
[NEUTRAL, CONGRUENT, INCONGRUENT].freeze
- BOX =
{ vertical: "┊", horizontal: "┄", top_left: "┌", top_right: "┐", bottom_left: "└", bottom_right: "┘" }.transform_values(&:light_black).freeze
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(rows:, columns:, mode:) ⇒ Set
constructor
A new instance of Set.
- #to_s ⇒ Object
Constructor Details
#initialize(rows:, columns:, mode:) ⇒ Set
Returns a new instance of Set.
25 26 27 28 29 30 31 |
# File 'lib/stroop/set.rb', line 25 def initialize(rows:, columns:, mode:) raise SetModeNotAvailable.new unless MODES.include?(mode) @rows = rows.to_i.abs @columns = columns.to_i.abs @mode = mode.to_sym end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
23 24 25 |
# File 'lib/stroop/set.rb', line 23 def columns @columns end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
23 24 25 |
# File 'lib/stroop/set.rb', line 23 def mode @mode end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
23 24 25 |
# File 'lib/stroop/set.rb', line 23 def rows @rows end |
Instance Method Details
#to_s ⇒ Object
33 34 35 |
# File 'lib/stroop/set.rb', line 33 def to_s [empty_line(:top), *lines, empty_line(:bottom)].join("\n") end |