Class: Smshelper::Message
- Inherits:
-
Object
- Object
- Smshelper::Message
- Defined in:
- lib/smshelper/message.rb
Instance Attribute Summary collapse
-
#recipient ⇒ Object
Returns the value of attribute recipient.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#text ⇒ Object
Returns the value of attribute text.
-
#utf_8 ⇒ Object
readonly
Returns the value of attribute utf_8.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Message
constructor
A new instance of Message.
- #is_gsm(text) ⇒ Object
-
#to_hex_be ⇒ Object
convert text to UCS-2 BigEndian.
Constructor Details
#initialize(attributes = {}) ⇒ Message
Returns a new instance of Message.
6 7 8 9 10 11 |
# File 'lib/smshelper/message.rb', line 6 def initialize(attributes = {}) @recipient = attributes[:recipient] @text = attributes[:text] @sender = attributes[:sender] is_gsm(@text) ? (@utf_8 = false) : (@utf_8 = true) end |
Instance Attribute Details
#recipient ⇒ Object
Returns the value of attribute recipient.
3 4 5 |
# File 'lib/smshelper/message.rb', line 3 def recipient @recipient end |
#sender ⇒ Object
Returns the value of attribute sender.
3 4 5 |
# File 'lib/smshelper/message.rb', line 3 def sender @sender end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/smshelper/message.rb', line 3 def text @text end |
#utf_8 ⇒ Object (readonly)
Returns the value of attribute utf_8.
4 5 6 |
# File 'lib/smshelper/message.rb', line 4 def utf_8 @utf_8 end |
Instance Method Details
#is_gsm(text) ⇒ Object
13 14 15 16 |
# File 'lib/smshelper/message.rb', line 13 def is_gsm(text) dl = Smshelper::Languagetools::Charset.new lang = dl.is_gsm(text) end |
#to_hex_be ⇒ Object
convert text to UCS-2 BigEndian
23 24 25 |
# File 'lib/smshelper/message.rb', line 23 def to_hex_be @text = @text.unpack('U*').collect {|x| sprintf '%04X', x}.join end |