Class: NMA::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-notify-my-android/notification.rb

Defined Under Namespace

Classes: NoAPIKeyGiven, NoApplicationNameGiven, NoDescriptionGiven

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Notification

Returns a new instance of Notification.



24
25
26
27
28
29
30
# File 'lib/ruby-notify-my-android/notification.rb', line 24

def initialize(params = {})
  @apikey = params[:apikey]
  @application  = params[:application]  || "NMA"
  @event        = params[:event]        || "NMA is working!!"
  @description  = params[:description]  || "This is the default description"
  @priority     = params[:priority]     || Priority::NORMAL
end

Instance Attribute Details

#apikeyObject



16
17
18
19
20
21
22
# File 'lib/ruby-notify-my-android/notification.rb', line 16

def apikey
  if @apikey.is_a? Array
    @apikey.join(',')
  else
    @apikey
  end
end

#applicationObject

Returns the value of attribute application.



12
13
14
# File 'lib/ruby-notify-my-android/notification.rb', line 12

def application
  @application
end

#descriptionObject

Returns the value of attribute description.



12
13
14
# File 'lib/ruby-notify-my-android/notification.rb', line 12

def description
  @description
end

#eventObject

Returns the value of attribute event.



13
14
15
# File 'lib/ruby-notify-my-android/notification.rb', line 13

def event
  @event
end

#priorityObject

Returns the value of attribute priority.



13
14
15
# File 'lib/ruby-notify-my-android/notification.rb', line 13

def priority
  @priority
end

#providerkeyObject

Returns the value of attribute providerkey.



13
14
15
# File 'lib/ruby-notify-my-android/notification.rb', line 13

def providerkey
  @providerkey
end

Instance Method Details

#to_paramsObject

Raises:



32
33
34
35
36
37
# File 'lib/ruby-notify-my-android/notification.rb', line 32

def to_params
  raise NoAPIKeyGiven if apikey.nil?
  raise NoApplicationNameGiven if @application.nil?
  raise NoDescriptionGiven if @description.nil?
  params.join('&')
end