Class: Grocer::Notification
- Inherits:
-
Object
- Object
- Grocer::Notification
- Defined in:
- lib/grocer/notification.rb
Instance Attribute Summary collapse
-
#alert ⇒ Object
Returns the value of attribute alert.
-
#badge ⇒ Object
Returns the value of attribute badge.
-
#custom ⇒ Object
Returns the value of attribute custom.
-
#device_token ⇒ Object
Returns the value of attribute device_token.
-
#expiry ⇒ Object
Returns the value of attribute expiry.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#sound ⇒ Object
Returns the value of attribute sound.
Instance Method Summary collapse
-
#initialize(payload = {}) ⇒ Notification
constructor
A new instance of Notification.
- #to_bytes ⇒ Object
Constructor Details
#initialize(payload = {}) ⇒ Notification
Returns a new instance of Notification.
9 10 11 12 13 14 15 |
# File 'lib/grocer/notification.rb', line 9 def initialize(payload = {}) @identifier = 0 payload.each do |key, val| send("#{key}=", val) end end |
Instance Attribute Details
#alert ⇒ Object
Returns the value of attribute alert.
6 7 8 |
# File 'lib/grocer/notification.rb', line 6 def alert @alert end |
#badge ⇒ Object
Returns the value of attribute badge.
6 7 8 |
# File 'lib/grocer/notification.rb', line 6 def badge @badge end |
#custom ⇒ Object
Returns the value of attribute custom.
6 7 8 |
# File 'lib/grocer/notification.rb', line 6 def custom @custom end |
#device_token ⇒ Object
Returns the value of attribute device_token.
6 7 8 |
# File 'lib/grocer/notification.rb', line 6 def device_token @device_token end |
#expiry ⇒ Object
Returns the value of attribute expiry.
6 7 8 |
# File 'lib/grocer/notification.rb', line 6 def expiry @expiry end |
#identifier ⇒ Object
Returns the value of attribute identifier.
6 7 8 |
# File 'lib/grocer/notification.rb', line 6 def identifier @identifier end |
#sound ⇒ Object
Returns the value of attribute sound.
6 7 8 |
# File 'lib/grocer/notification.rb', line 6 def sound @sound end |
Instance Method Details
#to_bytes ⇒ Object
17 18 19 20 21 22 |
# File 'lib/grocer/notification.rb', line 17 def to_bytes validate_payload payload = encoded_payload [1, identifier, expiry_epoch_time, device_token_length, sanitized_device_token, payload.length].pack('CNNnH64n') << payload end |