Class: Grepity::TargetFile
- Inherits:
-
Object
- Object
- Grepity::TargetFile
- Defined in:
- lib/grepity/target_file.rb
Instance Method Summary collapse
-
#initialize(file_name) ⇒ TargetFile
constructor
A new instance of TargetFile.
- #match(text) ⇒ Object
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 |