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

Create new port

Parameters:

  • data (Object)


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

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 True if serial port.

Returns:

  • (Boolean)

    True if serial port



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

def is_serial?
  @is_serial == true
end

#is_tcp?Boolean

Returns True if tcp port.

Returns:

  • (Boolean)

    True if tcp port



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

def is_tcp?
  @is_tcp == true
end

#to_sString

Returns port.

Returns:

  • (String)

    port



25
26
27
28
29
30
31
# File 'lib/artoo/port.rb', line 25

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