Class: Orefs::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/orefs/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

- (Remote) initialize

A new instance of Remote



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

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

Instance Attribute Details

- (Object) dir

Returns the value of attribute dir



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

def dir
  @dir
end

- (Object) host

Returns the value of attribute host



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

def host
  @host
end

- (Object) pass_file

Returns the value of attribute pass_file



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

def pass_file
  @pass_file
end

- (Object) user

Returns the value of attribute user



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

def user
  @user
end

Instance Method Details

- (Boolean) complete?

Returns:

  • (Boolean)


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

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

- (Boolean) encrypt?

Returns:

  • (Boolean)


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

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

- (Boolean) okay?

Returns:

  • (Boolean)


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

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

- (Object) to_s



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

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

- (Object) update(str)

Expects a string as input of the form user@remote.com:dir:passphrase_file



19
20
21
22
23
24
25
26
# File 'lib/orefs/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