Class: Codebreaker::Sorter

Inherits:
Object
  • Object
show all
Defined in:
lib/codebreaker/sorter.rb

Constant Summary collapse

CONDITIONAL_ARRAY =
i[hell medium easy].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Sorter

Returns a new instance of Sorter.



9
10
11
# File 'lib/codebreaker/sorter.rb', line 9

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/codebreaker/sorter.rb', line 7

def data
  @data
end

Instance Method Details

#callObject



13
14
15
16
17
18
# File 'lib/codebreaker/sorter.rb', line 13

def call
  sorted = sort_by_hints(data)
  sorted = sort_by_attempts(sorted)
  sorted = sort_by_difficulties(sorted)
  sorted
end