Class: Smshelper::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/smshelper/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#recipientObject

Returns the value of attribute recipient.



3
4
5
# File 'lib/smshelper/message.rb', line 3

def recipient
  @recipient
end

#senderObject

Returns the value of attribute sender.



3
4
5
# File 'lib/smshelper/message.rb', line 3

def sender
  @sender
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/smshelper/message.rb', line 3

def text
  @text
end

#utf_8Object (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_beObject

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