Class: Artoo::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/artoo/port.rb

Overview

The Artoo::Port class represents port and/or host to be used to connect tp a specific individual hardware device.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Port

Create new port



9
10
11
12
# File 'lib/artoo/port.rb', line 9

def initialize(data=nil)
  @is_tcp, @is_serial, @is_portless = false
  parse(data)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/artoo/port.rb', line 5

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/artoo/port.rb', line 5

def port
  @port
end

Instance Method Details

#is_portless?Boolean



25
26
27
# File 'lib/artoo/port.rb', line 25

def is_portless?
  @is_portless == true
end

#is_serial?Boolean



15
16
17
# File 'lib/artoo/port.rb', line 15

def is_serial?
  @is_serial == true
end

#is_tcp?Boolean



20
21
22
# File 'lib/artoo/port.rb', line 20

def is_tcp?
  @is_tcp == true
end

#to_sString



30
31
32
33
34
35
36
37
38
# File 'lib/artoo/port.rb', line 30

def to_s
  if is_portless?
    "none"
  elsif is_serial?
    port
  else
    "#{host}:#{port}"
  end
end