Class: Lf::Filter::Label

Inherits:
Lf::Filter show all
Defined in:
lib/lf/filter/label.rb

Constant Summary

Constants inherited from Lf::Filter

FILTERS

Instance Method Summary collapse

Methods inherited from Lf::Filter

[], []=, filter_alias, inherited, parse

Constructor Details

#initialize(arg) ⇒ Label

Returns a new instance of Label.



2
3
4
# File 'lib/lf/filter/label.rb', line 2

def initialize(arg)
  @labels = arg.split(',').map(&:strip)
end

Instance Method Details

#apply(row) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/lf/filter/label.rb', line 6

def apply(row)
  raw = row.reject do |key, _|
    !@labels.include?(key.to_s)
  end

  Lf::Row.new(raw)
end