Class: TTY::Table::Operations
- Inherits:
-
Object
- Object
- TTY::Table::Operations
- Defined in:
- lib/tty/table/operations.rb
Overview
A class holding table field operations
Instance Method Summary collapse
-
#add_operation(type, object) ⇒ Hash
Add operation.
-
#initialize(table) ⇒ Object
constructor
Initialize Operations.
-
#operations ⇒ Hash
Available operations.
-
#run_operations(type, row, options = {}) ⇒ Hash
Apply operations to a table row.
Constructor Details
#initialize(table) ⇒ Object
Initialize Operations
23 24 25 |
# File 'lib/tty/table/operations.rb', line 23 def initialize(table) @table = table end |
Instance Method Details
#add_operation(type, object) ⇒ Hash
Add operation
46 47 48 |
# File 'lib/tty/table/operations.rb', line 46 def add_operation(type, object) operations[type] << object end |
#operations ⇒ Hash
Available operations
32 33 34 |
# File 'lib/tty/table/operations.rb', line 32 def operations @operations ||= Hash.new { |hash, key| hash[key] = [] } end |
#run_operations(type, row, options = {}) ⇒ Hash
Apply operations to a table row
62 63 64 65 |
# File 'lib/tty/table/operations.rb', line 62 def run_operations(type, row, ={}) .merge!(:column_widths => table.column_widths) operations[type].each { |op| op.call(row, ) } end |