Class: Grepity::TargetFile

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

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ TargetFile

Returns a new instance of TargetFile.



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

def initialize(file_name)
  @lines = File.read(file_name).split("\n")
  @lines.map! { |line| Line.new(line, @lines.index(line)) }
end

Instance Method Details

#match(text) ⇒ Object



8
9
10
# File 'lib/grepity/target_file.rb', line 8

def match(text)
  @lines.select { |line| line.contents.match(text) }
end