Class: Stroop::Set
- Inherits:
-
Object
- Object
- Stroop::Set
- Defined in:
- lib/stroop/set.rb
Constant Summary collapse
- 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.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
-
#initialize(rows:, columns:, mode:, seed: nil) ⇒ Set
constructor
A new instance of Set.
- #to_s ⇒ Object
Constructor Details
#initialize(rows:, columns:, mode:, seed: nil) ⇒ Set
Returns a new instance of Set.
24 25 26 27 28 29 30 31 32 |
# File 'lib/stroop/set.rb', line 24 def initialize(rows:, columns:, mode:, seed: nil) raise SetModeNotAvailable.new unless MODES.include?(mode) @rows = rows.to_i.abs @columns = columns.to_i.abs @mode = mode.to_sym @generator = ColorGenerator.new(seed: seed) @seed = @generator.seed end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
22 23 24 |
# File 'lib/stroop/set.rb', line 22 def columns @columns end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
22 23 24 |
# File 'lib/stroop/set.rb', line 22 def mode @mode end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
22 23 24 |
# File 'lib/stroop/set.rb', line 22 def rows @rows end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
22 23 24 |
# File 'lib/stroop/set.rb', line 22 def seed @seed end |
Instance Method Details
#to_s ⇒ Object
34 35 36 |
# File 'lib/stroop/set.rb', line 34 def to_s [empty_line(:top), *lines, empty_line(:bottom)].join("\n") end |