Class: BMO::APNS::Notification::DeviceToken
- Inherits:
-
Object
- Object
- BMO::APNS::Notification::DeviceToken
- Defined in:
- lib/bmo/apns/notification.rb
Overview
The DeviceToken is the id of a Device for an App
Defined Under Namespace
Classes: MalformedDeviceToken
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(token) ⇒ DeviceToken
constructor
A new instance of DeviceToken.
- #to_package ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(token) ⇒ DeviceToken
Returns a new instance of DeviceToken.
75 76 77 |
# File 'lib/bmo/apns/notification.rb', line 75 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
73 74 75 |
# File 'lib/bmo/apns/notification.rb', line 73 def token @token end |
Instance Method Details
#to_package ⇒ Object
79 80 81 |
# File 'lib/bmo/apns/notification.rb', line 79 def to_package [token].pack('H*') end |
#validate! ⇒ Object
83 84 85 86 87 88 |
# File 'lib/bmo/apns/notification.rb', line 83 def validate! unless token =~ /^[a-z0-9]{64}$/i fail(MalformedDeviceToken, 'Malformed Device Token') end true end |