Class: ClEmoticon
- Inherits:
-
Object
- Object
- ClEmoticon
- Defined in:
- lib/messages/cl_emoticon.rb
Overview
ClEmoticon
Client -> Server
Instance Attribute Summary collapse
-
#emoticon ⇒ Object
Returns the value of attribute emoticon.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #init_hash(attr) ⇒ Object
- #init_raw(data) ⇒ Object
-
#initialize(hash_or_raw) ⇒ ClEmoticon
constructor
A new instance of ClEmoticon.
-
#to_a ⇒ Object
basically to_network int array the Client sends to the Server.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hash_or_raw) ⇒ ClEmoticon
Returns a new instance of ClEmoticon.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/messages/cl_emoticon.rb', line 12 def initialize(hash_or_raw) names = [ 'oop!', # 0 'alert', # 1 'heart', # 2 'tear', # 3 '...', # 4 'music', # 5 'sorry', # 6 'ghost', # 7 'annoyed', # 8 'angry', # 9 'devil', # 10 'swearing', # 11 'zzZ', # 12 'WTF', # 13 'happy', # 14 '???' # 15 ] if hash_or_raw.instance_of?(Hash) init_hash(hash_or_raw) else init_raw(hash_or_raw) end @name = names[@emoticon] end |
Instance Attribute Details
#emoticon ⇒ Object
Returns the value of attribute emoticon.
10 11 12 |
# File 'lib/messages/cl_emoticon.rb', line 10 def emoticon @emoticon end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/messages/cl_emoticon.rb', line 10 def name @name end |
Instance Method Details
#init_hash(attr) ⇒ Object
44 45 46 |
# File 'lib/messages/cl_emoticon.rb', line 44 def init_hash(attr) @emoticon = attr[:emoticon] || 0 end |
#init_raw(data) ⇒ Object
39 40 41 42 |
# File 'lib/messages/cl_emoticon.rb', line 39 def init_raw(data) u = Unpacker.new(data) @emoticon = u.get_int end |
#to_a ⇒ Object
basically to_network int array the Client sends to the Server
56 57 58 |
# File 'lib/messages/cl_emoticon.rb', line 56 def to_a Packer.pack_int(@emoticon) end |
#to_h ⇒ Object
48 49 50 51 52 |
# File 'lib/messages/cl_emoticon.rb', line 48 def to_h { emoticon: @emoticon } end |
#to_s ⇒ Object
60 61 62 |
# File 'lib/messages/cl_emoticon.rb', line 60 def to_s to_h end |