Class: DataHandler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDataHandler

Returns a new instance of DataHandler.



3
4
5
6
# File 'lib/data_handler.rb', line 3

def initialize
  @start_pairs = []
  @follower_letters = Hash.new('')
end

Instance Attribute Details

#follower_lettersObject (readonly)

Returns the value of attribute follower_letters.



2
3
4
# File 'lib/data_handler.rb', line 2

def follower_letters
  @follower_letters
end

#start_pairsObject (readonly)

Returns the value of attribute start_pairs.



2
3
4
# File 'lib/data_handler.rb', line 2

def start_pairs
  @start_pairs
end

Instance Method Details

#read_data_file(data_file) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/data_handler.rb', line 8

def read_data_file(data_file)
  File.open(data_file, 'r') do |file|
    chars = file.read.chomp.downcase.gsub(/\s/, ' ').chars.to_a
    chars.push(chars[0], chars[1])
    populate_followers_and_start_pairs(chars)
  end
end