Module: Command::DSL::Formatting
- Included in:
- Action
- Defined in:
- lib/command-set/dsl.rb
Overview
The DSL for formatting. A lot of code will do just fine with the Kernel#puts #that Results intercepts. More involved output control starts by including CommandSet::DSL::Formatting, and using Formatting#list and Formatting#item to structure output for the formatters.
Instance Method Summary collapse
-
#begin_list(name, options = {}) ⇒ Object
Tells the main collector to begin a list.
-
#end_list ⇒ Object
Tells the main collector to end the current list.
-
#item(name, options = {}) ⇒ Object
Clean way to create an item of output.
-
#list(name, options = {}) ⇒ Object
To create lists and sublist of data, you can use #list to wrap code in a #begin_list / #end_list pair.
Instance Method Details
#begin_list(name, options = {}) ⇒ Object
Tells the main collector to begin a list. Subsequent output will be gathered into that list. For more, check out Results::Collector
396 397 398 |
# File 'lib/command-set/dsl.rb', line 396 def begin_list(name, ={}) @main_collector.begin_list(name, ) end |
#end_list ⇒ Object
Tells the main collector to end the current list. For more, check out Results::Collector
402 403 404 |
# File 'lib/command-set/dsl.rb', line 402 def end_list @main_collector.end_list end |
#item(name, options = {}) ⇒ Object
Clean way to create an item of output. Allows for various options to be added. The normal output method (#puts, #p, #write…) are all diverted within a command, and effectively create no-option items.
409 410 411 |
# File 'lib/command-set/dsl.rb', line 409 def item(name, ={}) @main_collector.item(name, ) end |
#list(name, options = {}) ⇒ Object
To create lists and sublist of data, you can use #list to wrap code in a #begin_list / #end_list pair.
388 389 390 391 392 |
# File 'lib/command-set/dsl.rb', line 388 def list(name, ={}) #:yield: begin_list(name, ) yield if block_given? end_list end |