Class: ODisk::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/odisk/remote.rb

Overview

Just a way to keep the data associated with a remote site together one Object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRemote

Returns a new instance of Remote.



11
12
13
14
15
16
# File 'lib/odisk/remote.rb', line 11

def initialize()
  @user = nil
  @host = nil
  @dir = nil
  @pass_file = nil
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



8
9
10
# File 'lib/odisk/remote.rb', line 8

def dir
  @dir
end

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/odisk/remote.rb', line 7

def host
  @host
end

#pass_fileObject

Returns the value of attribute pass_file.



9
10
11
# File 'lib/odisk/remote.rb', line 9

def pass_file
  @pass_file
end

#userObject

Returns the value of attribute user.



6
7
8
# File 'lib/odisk/remote.rb', line 6

def user
  @user
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/odisk/remote.rb', line 28

def complete?()
  !(@user.nil? || @host.nil? || @dir.nil? || @pass_file.nil?)
end

#encrypt?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/odisk/remote.rb', line 36

def encrypt?()
  !@pass_file.nil?
end

#okay?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/odisk/remote.rb', line 32

def okay?()
  !(@user.nil? || @host.nil? || @dir.nil?)
end

#to_sObject



40
41
42
# File 'lib/odisk/remote.rb', line 40

def to_s()
  "#{user}@#{host}:#{@dir}:#{@pass_file}"
end

#update(str) ⇒ Object

Expects a string as input of the form [email protected]:dir:passphrase_file



19
20
21
22
23
24
25
26
# File 'lib/odisk/remote.rb', line 19

def update(str)
  u, x = str.strip().split('@')
  h, t, p = x.split(':')
  @user = u if @user.nil? && u.is_a?(String) && !u.empty?
  @host = h if @host.nil? && h.is_a?(String) && !h.empty?
  @dir = t if @dir.nil? && t.is_a?(String) && !t.empty?
  @pass_file = p if @pass_file.nil? && p.is_a?(String) && !p.empty?
end