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.
89 90 91 |
# File 'lib/bmo/apns/notification.rb', line 89 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
87 88 89 |
# File 'lib/bmo/apns/notification.rb', line 87 def token @token end |
Instance Method Details
#to_package ⇒ Object
93 94 95 |
# File 'lib/bmo/apns/notification.rb', line 93 def to_package [1, 32, token].pack('cnH64') end |
#validate! ⇒ Object
97 98 99 100 101 102 |
# File 'lib/bmo/apns/notification.rb', line 97 def validate! unless token =~ /^[a-z0-9]{64}$/i fail(MalformedDeviceToken, "Malformed Device Token : #{token}") end true end |