Module: DZEN::Macros
- Defined in:
- lib/dzen/macros.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#app(name, options = nil, &blk) ⇒ Object
Public: Add new handler for an app.
-
#before_run(&blk) ⇒ Object
Public: Add before_run handler.
-
#configure(&blk) ⇒ Object
Public: Configure the instance.
-
#dzen ⇒ Object
Public: Gets the current DZEN instance.
-
#order(*apps) ⇒ Object
Public: Set the order of apps.
-
#run? ⇒ Boolean
Public: Gets wether to run the DZEN output at exit or not.
Class Method Details
.included(mod) ⇒ Object
5 6 7 |
# File 'lib/dzen/macros.rb', line 5 def self.included(mod) @@dzen = nil end |
Instance Method Details
#app(name, options = nil, &blk) ⇒ Object
Public: Add new handler for an app.
name - Name of the app. option - Some options [not used yet]. blk - The actual handler block.
44 45 46 |
# File 'lib/dzen/macros.rb', line 44 def app(name, =nil, &blk) dzen.add_handler(name, , &blk) end |
#before_run(&blk) ⇒ Object
Public: Add before_run handler.
blk - The block to be run when starting
35 36 37 |
# File 'lib/dzen/macros.rb', line 35 def before_run(&blk) dzen.add_before_run(&blk) end |
#configure(&blk) ⇒ Object
Public: Configure the instance.
The block will be yielded the current configuration.
Example:
configure do |c|
c.interval = 3
end
Returns the config
19 20 21 |
# File 'lib/dzen/macros.rb', line 19 def configure(&blk) dzen.configure(&blk) end |
#dzen ⇒ Object
Public: Gets the current DZEN instance.
Define TERMINAL or ENV to use DZEN::Terminal instead of DZEN::Default.
Returns a newly created or currently existing DZEN instance.
54 55 56 57 58 59 60 61 |
# File 'lib/dzen/macros.rb', line 54 def dzen return @@dzen unless @@dzen.nil? @@dzen = DZEN::Terminal.new if defined?(::TERMINAL) || !!ENV['TERMINAL'] @@dzen = DZEN::Default.new unless @@dzen @@dzen end |
#order(*apps) ⇒ Object
Public: Set the order of apps.
apps - App names in sorted order.
Returns the passed order array.
28 29 30 |
# File 'lib/dzen/macros.rb', line 28 def order(*apps) dzen.order = apps end |
#run? ⇒ Boolean
Public: Gets wether to run the DZEN output at exit or not.
Returns a boolean.
66 67 68 |
# File 'lib/dzen/macros.rb', line 66 def run? !!@@dzen end |