Class: Grepity::Line

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents, number) ⇒ Line

Returns a new instance of Line.



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

def initialize(contents, number)
  @contents, @number = contents, number + 1
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



5
6
7
# File 'lib/grepity/line.rb', line 5

def contents
  @contents
end

#numberObject (readonly)

Returns the value of attribute number.



5
6
7
# File 'lib/grepity/line.rb', line 5

def number
  @number
end

Instance Method Details

#result(text, options = {}) ⇒ Object



11
12
13
14
# File 'lib/grepity/line.rb', line 11

def result(text, options = {})
  return colorized_line_with_text(number, text) if options[:line]
  colorized_text(text)
end