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.
275 276 277 |
# File 'lib/term_utils/tab.rb', line 275 def initialize(opts = {}) @tables = {} end |
Instance Attribute Details
#tables ⇒ Hash<Symbol, Tab::Table>
274 275 276 |
# File 'lib/term_utils/tab.rb', line 274 def tables @tables end |
Instance Method Details
#define_table(id, opts = {}, &block) ⇒ Tab::Table
Defines a table.
282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/term_utils/tab.rb', line 282 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.
296 297 298 |
# File 'lib/term_utils/tab.rb', line 296 def find_table(id) @tables[id] end |
#printer(id, io, opts = {}, &block) ⇒ Tab::Printer
Creates a new table printer.
307 308 309 |
# File 'lib/term_utils/tab.rb', line 307 def printer(id, io, opts = {}, &block) find_table(id).printer(io, opts, &block) end |