Class: TextReader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_text_file) ⇒ TextReader

Returns a new instance of TextReader.



4
5
6
7
8
# File 'lib/io/text_reader.rb', line 4

def initialize(input_text_file)
  @input_text_file = input_text_file
  @beginnings = []
  @lines = []
end

Instance Attribute Details

#beginningsObject

Returns the value of attribute beginnings.



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

def beginnings
  @beginnings
end

#linesObject

Returns the value of attribute lines.



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

def lines
  @lines
end

Instance Method Details

#process_input_text_fileObject



10
11
12
13
14
# File 'lib/io/text_reader.rb', line 10

def process_input_text_file
  @lines = File.readlines(@input_text_file)
  @beginnings = @lines.collect { |s| s.split(' ').first }.reject { |w| w.nil? }
  return self
end