Class: Player::Header
- Inherits:
-
Object
- Object
- Player::Header
- Includes:
- Common
- Defined in:
- lib/ruby-player/header.rb
Overview
Header of message
Instance Attribute Summary collapse
-
#dev_addr ⇒ Object
readonly
Returns the value of attribute dev_addr.
-
#seq ⇒ Object
readonly
Returns the value of attribute seq.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#subtype ⇒ Object
readonly
Returns the value of attribute subtype.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #encode ⇒ Object
-
#initialize(param = {}) ⇒ Header
constructor
A new instance of Header.
- #subtype_name ⇒ Object
- #to_s ⇒ Object
- #type_name ⇒ Object
Constructor Details
#initialize(param = {}) ⇒ Header
Returns a new instance of Header.
22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby-player/header.rb', line 22 def initialize(param = {}) @dev_addr = param[:dev_addr] || DevAddr.new @type = param[:type].to_i @subtype = param[:subtype].to_i @time = param[:time] || Time.now.to_f / 1000 @seq = param[:seq].to_i @size = param[:size].to_i end |
Instance Attribute Details
#dev_addr ⇒ Object (readonly)
Returns the value of attribute dev_addr.
20 21 22 |
# File 'lib/ruby-player/header.rb', line 20 def dev_addr @dev_addr end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
20 21 22 |
# File 'lib/ruby-player/header.rb', line 20 def seq @seq end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
20 21 22 |
# File 'lib/ruby-player/header.rb', line 20 def size @size end |
#subtype ⇒ Object (readonly)
Returns the value of attribute subtype.
20 21 22 |
# File 'lib/ruby-player/header.rb', line 20 def subtype @subtype end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
20 21 22 |
# File 'lib/ruby-player/header.rb', line 20 def time @time end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
20 21 22 |
# File 'lib/ruby-player/header.rb', line 20 def type @type end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
46 47 48 |
# File 'lib/ruby-player/header.rb', line 46 def ==(other) @dev_addr == other.dev_addr and @type == other.type and @subtype == other.subtype and @time == other.time and @seq == other.seq and @size == other.size end |
#encode ⇒ Object
42 43 44 |
# File 'lib/ruby-player/header.rb', line 42 def encode @dev_addr.encode + [@type, @subtype, @time, @seq, @size].pack("NNGNN") end |
#subtype_name ⇒ Object
58 59 60 |
# File 'lib/ruby-player/header.rb', line 58 def subtype_name @subtype_name ||= search_msg_subtype_name(dev_addr.interface_name, type_name, @subtype) end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/ruby-player/header.rb', line 50 def to_s "header to #@dev_addr of message [type=#{type_name}, subtype=#{subtype_name}, size=#@size]" end |
#type_name ⇒ Object
54 55 56 |
# File 'lib/ruby-player/header.rb', line 54 def type_name @type_name ||= search_msg_type_name(@type) end |