Class: TermUtils::Tab::Holder
- Inherits:
-
Object
- Object
- TermUtils::Tab::Holder
- Defined in:
- lib/term_utils/tab.rb
Overview
Represents a holder of tables.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#define_table(id, opts = {}, &block) ⇒ Tab::Table
Defines a table.
-
#find_table(id) ⇒ Tab::Table?
Finds a table.
-
#initialize(opts = {}) ⇒ Holder
constructor
A new instance of Holder.
-
#printer(id, io, opts = {}, &block) ⇒ Tab::Printer
Creates a new table printer.
Constructor Details
#initialize(opts = {}) ⇒ Holder
Returns a new instance of Holder
290 291 292 |
# File 'lib/term_utils/tab.rb', line 290 def initialize(opts = {}) @tables = {} end |
Instance Attribute Details
#tables ⇒ Hash<Symbol, Tab::Table>
289 290 291 |
# File 'lib/term_utils/tab.rb', line 289 def tables @tables end |
Instance Method Details
#define_table(id, opts = {}, &block) ⇒ Tab::Table
Defines a table.
297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/term_utils/tab.rb', line 297 def define_table(id, opts = {}, &block) if @tables.has_key? id block.call(@tables[id]) if block else opts[:id] = id new_tab = Table.new(opts) block.call(new_tab) if block @tables[id] = new_tab end @tables[id] end |
#find_table(id) ⇒ Tab::Table?
Finds a table.
311 312 313 |
# File 'lib/term_utils/tab.rb', line 311 def find_table(id) @tables[id] end |
#printer(id, io, opts = {}, &block) ⇒ Tab::Printer
Creates a new table printer.
321 322 323 |
# File 'lib/term_utils/tab.rb', line 321 def printer(id, io, opts = {}, &block) find_table(id).printer(io, opts, &block) end |