Class: Stroop::Set

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#columnsObject (readonly)

Returns the value of attribute columns.



23
24
25
# File 'lib/stroop/set.rb', line 23

def columns
  @columns
end

#modeObject (readonly)

Returns the value of attribute mode.



23
24
25
# File 'lib/stroop/set.rb', line 23

def mode
  @mode
end

#rowsObject (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_sObject



33
34
35
# File 'lib/stroop/set.rb', line 33

def to_s
  [empty_line(:top), *lines, empty_line(:bottom)].join("\n")
end