Class: Gaurun::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/gaurun-ruby/notification.rb

Defined Under Namespace

Classes: Android, IOS, PlatformAbstract

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message: '') ⇒ Notification

Returns a new instance of Notification.



7
8
9
10
# File 'lib/gaurun-ruby/notification.rb', line 7

def initialize(message: '')
  @ios     = Gaurun::Notification::IOS.new(message: message)
  @android = Gaurun::Notification::Android.new(message: message)
end

Instance Attribute Details

#androidObject

Returns the value of attribute android.



5
6
7
# File 'lib/gaurun-ruby/notification.rb', line 5

def android
  @android
end

#iosObject

Returns the value of attribute ios.



5
6
7
# File 'lib/gaurun-ruby/notification.rb', line 5

def ios
  @ios
end

Instance Method Details

#payloadObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gaurun-ruby/notification.rb', line 12

def payload
  notifications = [
    @ios.payload,
    @android.payload,
  ].delete_if { |v| v.empty? }

  return nil if notifications.empty?
  {
    notifications: notifications,
  }
end