Class: Player::DevAddr
- Inherits:
-
Object
- Object
- Player::DevAddr
- Includes:
- Common
- Defined in:
- lib/ruby-player/dev_addr.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
-
#robot ⇒ Object
readonly
Returns the value of attribute robot.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #encode ⇒ Object
-
#initialize(addr = {}) ⇒ DevAddr
constructor
A new instance of DevAddr.
- #interface_name ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(addr = {}) ⇒ DevAddr
Returns a new instance of DevAddr.
21 22 23 24 25 26 |
# File 'lib/ruby-player/dev_addr.rb', line 21 def initialize(addr = {}) @host = addr[:host].to_i @robot = addr[:robot].to_i @interface = addr[:interface].to_i @index = addr[:index].to_i end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
19 20 21 |
# File 'lib/ruby-player/dev_addr.rb', line 19 def host @host end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
19 20 21 |
# File 'lib/ruby-player/dev_addr.rb', line 19 def index @index end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
19 20 21 |
# File 'lib/ruby-player/dev_addr.rb', line 19 def interface @interface end |
#robot ⇒ Object (readonly)
Returns the value of attribute robot.
19 20 21 |
# File 'lib/ruby-player/dev_addr.rb', line 19 def robot @robot end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
41 42 43 |
# File 'lib/ruby-player/dev_addr.rb', line 41 def ==(other) @host == other.host and @robot == other.robot and @interface == other.interface and @index == other.index end |
#encode ⇒ Object
33 34 35 |
# File 'lib/ruby-player/dev_addr.rb', line 33 def encode [@host, @robot, @interface, @index].pack("NNNN") end |
#interface_name ⇒ Object
37 38 39 |
# File 'lib/ruby-player/dev_addr.rb', line 37 def interface_name @interface_name ||= search_interface_name(@interface) end |
#to_a ⇒ Object
49 50 51 |
# File 'lib/ruby-player/dev_addr.rb', line 49 def to_a [@host, @robot, @interface, @index] end |
#to_s ⇒ Object
45 46 47 |
# File 'lib/ruby-player/dev_addr.rb', line 45 def to_s "device addr [#@host:#@robot] #{interface_name}:#@index" end |