Class: Rungs::Climb

Inherits:
Object
  • Object
show all
Includes:
PayDirt::UseCase
Defined in:
lib/rungs/climb.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Climb

Returns a new instance of Climb.



7
8
9
10
11
12
13
14
15
16
# File 'lib/rungs/climb.rb', line 7

def initialize(options = {})
  options = {
    list: "selected_four-letter_words.txt",
    steps: 1,
    file_class: File,
    word_ladder_class: Rungs::WordLadder
  }.merge(options)

  load_options(options)
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rungs/climb.rb', line 18

def call
  ret_hash = {}

  @file_class.readlines(@list).each do |word|
    ret_hash[word.chomp] = @word_ladder_class.new({
      word:  word.chomp,
      list:  @list,
      steps: @steps
    }).call.data
  end

  return result(true, ret_hash)
end