Class: Vaulty::Output::HighlightFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/vaulty/output/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matching: [], color: :red) ⇒ HighlightFilter

Returns a new instance of HighlightFilter.



5
6
7
8
# File 'lib/vaulty/output/table.rb', line 5

def initialize(matching: [], color: :red)
  @matching = matching
  @color = color
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



4
5
6
# File 'lib/vaulty/output/table.rb', line 4

def color
  @color
end

#matchingObject (readonly)

Returns the value of attribute matching.



4
5
6
# File 'lib/vaulty/output/table.rb', line 4

def matching
  @matching
end

Instance Method Details

#call(val, _row, _column) ⇒ Object



10
11
12
# File 'lib/vaulty/output/table.rb', line 10

def call(val, _row, _column)
  matching.include?(val.strip) ? pastel.decorate(val, color) : val
end

#pastelObject



14
15
16
# File 'lib/vaulty/output/table.rb', line 14

def pastel
  Pastel::Color.new(enabled: true)
end