Class: Pushbots::Push

Inherits:
Object
  • Object
show all
Defined in:
lib/pushbots/push.rb

Overview

Push class Holds shared data between single and batch push notifications

Direct Known Subclasses

All, One

Constant Summary collapse

PLATFORM_TYPE =
{ ios: 0, android: 1, chrome: 2 }.freeze
PLATFORM_TYPE_R =
[:ios, :android, :chrome].freeze
STATUS =
{ created: 'created', delivered: 'delivered',
failed: 'failed' }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform, message, type) ⇒ Push

Returns a new instance of Push.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pushbots/push.rb', line 12

def initialize(platform, message, type)
  self.type = type
  if type == :one
    validates_platform(platform)
    self.platform = PLATFORM_TYPE[platform]
  elsif type == :all
    validates_platforms(platform)
    self.platform = platform.map { |t| PLATFORM_TYPE[t] }
  end
  self.message = message
  self.status = STATUS[:created]
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/pushbots/push.rb', line 5

def message
  @message
end

#platformObject

Returns the value of attribute platform.



5
6
7
# File 'lib/pushbots/push.rb', line 5

def platform
  @platform
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/pushbots/push.rb', line 5

def response
  @response
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/pushbots/push.rb', line 5

def status
  @status
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/pushbots/push.rb', line 5

def type
  @type
end