Class: CLI::Proxy
- Inherits:
-
Object
- Object
- CLI::Proxy
- Defined in:
- lib/cli/app.rb
Overview
Proxy class is responsible for cool DSL inside CLI.app do … end block
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
-
#binary(val) ⇒ Object
Sets the App binary_name.
-
#default(&block) ⇒ Object
Defines the default action.
-
#initialize(app) ⇒ Proxy
constructor
A new instance of Proxy.
-
#method_missing(name, *attrs, &block) ⇒ Object
Delegates to App.
-
#name(val) ⇒ Object
Sets the App name.
-
#option(*args, &block) ⇒ Object
Define option for OptionParser.
-
#version(val) ⇒ Object
Sets the App version.
Constructor Details
#initialize(app) ⇒ Proxy
Returns a new instance of Proxy.
70 71 72 |
# File 'lib/cli/app.rb', line 70 def initialize(app) @app = app end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *attrs, &block) ⇒ Object
Delegates to App
100 101 102 |
# File 'lib/cli/app.rb', line 100 def method_missing(name, *attrs, &block) app.send(name, *attrs, &block) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
68 69 70 |
# File 'lib/cli/app.rb', line 68 def app @app end |
Instance Method Details
#binary(val) ⇒ Object
Sets the App binary_name
75 76 77 |
# File 'lib/cli/app.rb', line 75 def binary(val) app.binary = val end |
#default(&block) ⇒ Object
Defines the default action
90 91 92 |
# File 'lib/cli/app.rb', line 90 def default(&block) app.action("default", &block) end |
#name(val) ⇒ Object
Sets the App name
80 81 82 |
# File 'lib/cli/app.rb', line 80 def name(val) app.name = val end |
#option(*args, &block) ⇒ Object
Define option for OptionParser
95 96 97 |
# File 'lib/cli/app.rb', line 95 def option(*args, &block) app.opts.on(*args, &block) end |
#version(val) ⇒ Object
Sets the App version
85 86 87 |
# File 'lib/cli/app.rb', line 85 def version(val) app.version = val end |