Class: PduSms::DestinationAddress
- Defined in:
- lib/pdu_sms/destination_address.rb
Instance Attribute Summary
Attributes inherited from Phone
#number_plan_identifier, #type_number
Class Method Summary collapse
-
.cut_off_pdu(pdu, part = :all, type = :ms) ⇒ Object
tail current.
- .decode_ms(pdu) ⇒ Object
- .encode_ms(phone_number, number_play_identifier = false, type_number = false) ⇒ Object
Instance Method Summary collapse
- #get_hex ⇒ Object
-
#initialize(type = false, data = false, number_play_identifier = false, type_number = false) ⇒ DestinationAddress
constructor
A new instance of DestinationAddress.
Methods inherited from Phone
Constructor Details
#initialize(type = false, data = false, number_play_identifier = false, type_number = false) ⇒ DestinationAddress
Returns a new instance of DestinationAddress.
4 5 6 7 8 9 10 |
# File 'lib/pdu_sms/destination_address.rb', line 4 def initialize(type=false, data=false, number_play_identifier=false, type_number=false) if type == :decode_ms _set_pdu_hex data elsif type == :encode_ms _set_phone_number data, number_play_identifier, type_number end end |
Class Method Details
.cut_off_pdu(pdu, part = :all, type = :ms) ⇒ Object
tail current
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pdu_sms/destination_address.rb', line 20 def DestinationAddress.cut_off_pdu(pdu, part=:all, type=:ms) # tail current part_pdu = MessageReference.cut_off_pdu(pdu, :tail) raise ArgumentError, 'The "pdu" is incorrect' if part_pdu.length < 4 length = part_pdu[0..1].to_i(16) if length % 2 == 0 current = part_pdu[0..length+3] tail = part_pdu[length+4..-1] else current = part_pdu[0..length+4] tail = part_pdu[length+5..-1] end case part when :current then current when :tail then tail else [current,tail] end end |
.decode_ms(pdu) ⇒ Object
16 17 18 |
# File 'lib/pdu_sms/destination_address.rb', line 16 def DestinationAddress.decode_ms(pdu) new(:decode_ms, DestinationAddress.cut_off_pdu(pdu, :current, :ms)).freeze end |
.encode_ms(phone_number, number_play_identifier = false, type_number = false) ⇒ Object
12 13 14 |
# File 'lib/pdu_sms/destination_address.rb', line 12 def DestinationAddress.encode_ms(phone_number, number_play_identifier=false, type_number=false) new(:encode_ms, phone_number, number_play_identifier, type_number).freeze end |
Instance Method Details
#get_hex ⇒ Object
38 39 40 |
# File 'lib/pdu_sms/destination_address.rb', line 38 def get_hex '%s%s' % [_address_length, _get_hex_type_and_phone] end |