Class: Lynx::Command::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/lynx/command/basic.rb

Direct Known Subclasses

Dump

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#configObject (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

#authorizeObject



24
25
26
27
28
29
30
# File 'lib/lynx/command/basic.rb', line 24

def authorize
  @command << "--user=#{config.username}" if config.username
  @command << "--password=#{config.password}" if config.password
  @command << "--host=#{config.host}" if config.host

  self
end

#to_sObject



49
50
51
# File 'lib/lynx/command/basic.rb', line 49

def to_s
  @command.join(' ')
end