Class: Lynx::Command::Basic
- Inherits:
-
Object
- Object
- Lynx::Command::Basic
- Defined in:
- lib/lynx/command/basic.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.instruct(method, &block) ⇒ Object
A declarative way to generate chaining commands.
Instance Method Summary collapse
- #authorize ⇒ Object
-
#initialize(config) ⇒ Basic
constructor
A new instance of Basic.
- #option(option) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config) ⇒ Basic
Returns a new instance of Basic.
18 19 20 21 |
# File 'lib/lynx/command/basic.rb', line 18 def initialize(config) @config = config @command = [] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/lynx/command/basic.rb', line 6 def config @config end |
Class Method Details
.instruct(method, &block) ⇒ Object
A declarative way to generate chaining commands.
10 11 12 13 14 15 |
# File 'lib/lynx/command/basic.rb', line 10 def instruct(method, &block) define_method(method) do |*args| @command << block.call(self,*args) self end end |
Instance Method Details
#authorize ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/lynx/command/basic.rb', line 29 def @command << "--defaults-extra-file=#{config.credentials}" if config.credentials @command << "--user=#{config.username}" if config.username @command << "--host=#{config.host}" if config.host @command << "--socket=#{config.socket}" if config.socket self end |
#option(option) ⇒ Object
23 24 25 26 27 |
# File 'lib/lynx/command/basic.rb', line 23 def option(option) @command << option self end |
#to_s ⇒ Object
56 57 58 |
# File 'lib/lynx/command/basic.rb', line 56 def to_s @command.join(' ') end |