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.
- #to_s ⇒ Object
Constructor Details
#initialize(config) ⇒ Basic
Returns a new instance of Basic.
19 20 21 22 |
# File 'lib/lynx/command/basic.rb', line 19 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 16 |
# 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
24 25 26 27 28 29 30 |
# File 'lib/lynx/command/basic.rb', line 24 def @command << "--user=#{config.username}" if config.username @command << "--password=#{config.password}" if config.password @command << "--host=#{config.host}" if config.host self end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/lynx/command/basic.rb', line 49 def to_s @command.join(' ') end |