Class: Wordle::ResultBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/wordle/result_builder.rb

Constant Summary collapse

MATCH =
:match
INCLUDED =
:included
MISS =
:miss
DEFAULT_OPTIONS =
{
  MATCH => {text: :green, square: "🟩"},
  INCLUDED => {text: :yellow, square: "🟨"},
  MISS => {text: :gray, square: "⬛️"}
}.freeze
CONTRAST_OPTIONS =
{
  MATCH => {text: :orange, square: "🟧"},
  INCLUDED => {text: :blue, square: "🟦"},
  MISS => {text: :gray, square: "⬛️"}
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(contrast = false) ⇒ ResultBuilder

Returns a new instance of ResultBuilder.



21
22
23
# File 'lib/wordle/result_builder.rb', line 21

def initialize(contrast = false)
  @contrast = contrast
end

Instance Method Details

#includedObject



37
38
39
# File 'lib/wordle/result_builder.rb', line 37

def included
  INCLUDED
end

#included?(result) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/wordle/result_builder.rb', line 29

def included?(result)
  result == INCLUDED
end

#included_text_colorObject



49
50
51
# File 'lib/wordle/result_builder.rb', line 49

def included_text_color
  options[included][:text]
end

#matchObject



33
34
35
# File 'lib/wordle/result_builder.rb', line 33

def match
  MATCH
end

#match?(result) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/wordle/result_builder.rb', line 25

def match?(result)
  result == MATCH
end

#match_text_colorObject



45
46
47
# File 'lib/wordle/result_builder.rb', line 45

def match_text_color
  options[match][:text]
end

#missObject



41
42
43
# File 'lib/wordle/result_builder.rb', line 41

def miss
  MISS
end

#square(result) ⇒ Object



57
58
59
# File 'lib/wordle/result_builder.rb', line 57

def square(result)
  options[result][:square]
end

#text_color(result) ⇒ Object



53
54
55
# File 'lib/wordle/result_builder.rb', line 53

def text_color(result)
  options[result][:text]
end