Class: Rubygrep::Outputter

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

Constant Summary collapse

COLORS =
{red: 31, magenta: 35}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Outputter

Returns a new instance of Outputter.



8
9
10
# File 'lib/rubygrep/outputter.rb', line 8

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/rubygrep/outputter.rb', line 6

def options
  @options
end

Instance Method Details

#error(message, line_data) ⇒ Object



16
17
18
# File 'lib/rubygrep/outputter.rb', line 16

def error(message, line_data)
  $stdout << "#{colorize(line_data[:path])}: #{message}\n"
end

#out(match_data, line_data) ⇒ Object



12
13
14
# File 'lib/rubygrep/outputter.rb', line 12

def out(match_data, line_data)
  $stdout << format_with_options(match_data, line_data)
end