Class: TTY::Table::Operation::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/table/operation/filter.rb

Overview

A class responsible for transforming table field

Instance Method Summary collapse

Constructor Details

#initialize(filter) ⇒ Filter

Initialize a Filter



13
14
15
# File 'lib/tty/table/operation/filter.rb', line 13

def initialize(filter)
  @filter = filter
end

Instance Method Details

#call(field, row, col) ⇒ Object

Apply filer to the provided table field

Parameters:

  • field (TTY::Table::Field)
  • row (Integer)

    the field row index

  • col (Integer)

    the field column index



28
29
30
# File 'lib/tty/table/operation/filter.rb', line 28

def call(field, row, col)
  field.value = @filter.call(field.value, row, col)
end