Class: Omniscient::Ssh

Inherits:
Object
  • Object
show all
Defined in:
lib/omniscient/ssh.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Ssh

Returns a new instance of Ssh.



4
5
6
# File 'lib/omniscient/ssh.rb', line 4

def initialize( config )
  @attributes = config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/omniscient/ssh.rb', line 8

def method_missing( name, *args, &block )
  if args.empty? && block.nil? 
    if @attributes.has_key?(name.to_s) 
      @attributes[name.to_s]
    elsif @attributes.has_key?(name.to_sym) 
      @attributes[name.to_sym]
    else
      nil
    end
  else
    nil
  end
end

Instance Method Details

#connect(custom_message = '') ⇒ Object



27
28
29
30
31
# File 'lib/omniscient/ssh.rb', line 27

def connect( custom_message = '' )
  command = "ssh "+self.get_address.to_s
  command << " '"+custom_message+"'" unless custom_message.empty?
  command.to_s
end

#get_addressObject



22
23
24
25
# File 'lib/omniscient/ssh.rb', line 22

def get_address
  return false unless self.address
  self.address
end