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) ⇒ Port

Returns a new instance of Port.



7
8
9
10
# File 'lib/artoo/port.rb', line 7

def initialize(data)
  @is_tcp, @is_serial = 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_serial?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/artoo/port.rb', line 12

def is_serial?
  @is_serial == true
end

#is_tcp?Boolean

Returns:

  • (Boolean)


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

def is_tcp?
  @is_tcp == true
end

#to_sObject



20
21
22
23
24
25
26
# File 'lib/artoo/port.rb', line 20

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