Class: APNS::Packager

Inherits:
Object
  • Object
show all
Defined in:
lib/apns/packager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(notification) ⇒ Packager

Returns a new instance of Packager.



6
7
8
# File 'lib/apns/packager.rb', line 6

def initialize(notification)
  @notification = notification
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/apns/packager.rb', line 10

def method_missing(meth, *args, &block)
  if %w[device_token alert badge sound other].include?(meth.to_s)
    notification.send(meth, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#notificationObject (readonly)

Returns the value of attribute notification.



4
5
6
# File 'lib/apns/packager.rb', line 4

def notification
  @notification
end

Instance Method Details

#packageObject



18
19
20
# File 'lib/apns/packager.rb', line 18

def package
  [0, 0, 32, token, 0, message.bytesize, message].pack('ccca*cca*')
end