Class: Artoo::Port
- Inherits:
-
Object
- Object
- Artoo::Port
- 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
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(data = nil) ⇒ Port
constructor
Create new port.
-
#is_portless? ⇒ Boolean
True if does not have real port.
-
#is_serial? ⇒ Boolean
True if serial port.
-
#is_tcp? ⇒ Boolean
True if tcp port.
-
#to_s ⇒ String
Port.
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
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/artoo/port.rb', line 5 def host @host end |
#port ⇒ Object (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
Returns True if does not have real port.
25 26 27 |
# File 'lib/artoo/port.rb', line 25 def is_portless? @is_portless == true end |
#is_serial? ⇒ Boolean
Returns 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.
20 21 22 |
# File 'lib/artoo/port.rb', line 20 def is_tcp? @is_tcp == true end |
#to_s ⇒ String
Returns port.
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 |