Class: GuessOS::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/guess_os/host.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Host

Returns a new instance of Host.



8
9
10
11
12
13
14
# File 'lib/guess_os/host.rb', line 8

def initialize(args = {})
  @ip = args[:ip] || "localhost"
  @port = args[:port] || "22"
  @username = args[:username] || "vagrant"
  @password = args[:password] || "vagrant"
  @os = GuessOS::Type.guess(self)
end

Instance Attribute Details

#ipObject (readonly)

Returns the value of attribute ip.



5
6
7
# File 'lib/guess_os/host.rb', line 5

def ip
  @ip
end

#osObject (readonly)

Returns the value of attribute os.



6
7
8
# File 'lib/guess_os/host.rb', line 6

def os
  @os
end

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/guess_os/host.rb', line 5

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/guess_os/host.rb', line 5

def port
  @port
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/guess_os/host.rb', line 5

def username
  @username
end

Class Method Details

.unkownObject



26
27
28
# File 'lib/guess_os/host.rb', line 26

def self.unkown
  GuessOS::OS.new(:unkown, :unkown, "Unkown")
end

Instance Method Details

#local?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/guess_os/host.rb', line 16

def local?
  return true if (ip == "localhost") || (ip == "127.0.0.1")

  false
end

#remote?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/guess_os/host.rb', line 22

def remote?
  !local?
end