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.



18
19
20
21
# File 'lib/lynx/command/basic.rb', line 18

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



29
30
31
32
33
34
35
36
# File 'lib/lynx/command/basic.rb', line 29

def authorize
  @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_sObject



56
57
58
# File 'lib/lynx/command/basic.rb', line 56

def to_s
  @command.join(' ')
end