Class: MQTTPipe::Types::Color
- Inherits:
-
Object
- Object
- MQTTPipe::Types::Color
- Defined in:
- lib/mqtt_pipe/types/color.rb
Constant Summary collapse
- PACKER_CODE =
0xC9
Instance Attribute Summary collapse
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#g ⇒ Object
readonly
Returns the value of attribute g.
-
#r ⇒ Object
readonly
Returns the value of attribute r.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(r, g, b) ⇒ Color
constructor
A new instance of Color.
- #to_packed ⇒ Object
Constructor Details
#initialize(r, g, b) ⇒ Color
Returns a new instance of Color.
8 9 10 |
# File 'lib/mqtt_pipe/types/color.rb', line 8 def initialize r, g, b @r, @g, @b = r, g, b end |
Instance Attribute Details
#b ⇒ Object (readonly)
Returns the value of attribute b.
6 7 8 |
# File 'lib/mqtt_pipe/types/color.rb', line 6 def b @b end |
#g ⇒ Object (readonly)
Returns the value of attribute g.
6 7 8 |
# File 'lib/mqtt_pipe/types/color.rb', line 6 def g @g end |
#r ⇒ Object (readonly)
Returns the value of attribute r.
6 7 8 |
# File 'lib/mqtt_pipe/types/color.rb', line 6 def r @r end |
Class Method Details
.from_packed(_, raw) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/mqtt_pipe/types/color.rb', line 18 def from_packed _, raw color = 3.times.map do Packer.read_packed_bytes(1, from: raw, as: 'C') end new *color end |
Instance Method Details
#to_packed ⇒ Object
12 13 14 |
# File 'lib/mqtt_pipe/types/color.rb', line 12 def to_packed [PACKER_CODE, r, g, b].pack 'C4' end |