Class: Pling::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/pling/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Message #initialize(attributes) ⇒ Message

Creates a new Pling::Message instance with the given body

Overloads:

  • #initialize(body) ⇒ Message

    Parameters:

    • body (#to_s)
  • #initialize(attributes) ⇒ Message

    Parameters:

    • attributes (Hash)

    Options Hash (attributes):

    • :body (#to_s)


100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/pling/message.rb', line 100

def initialize(*args)
  attributes = case param = args.shift
    when String
      (args.last || {}).merge(:body => param)
    when Hash
      param
    else
      {}
  end

  attributes.each_pair do |key, value|
    method = "#{key}="
    send(method, value) if respond_to?(method)
  end
end

Instance Attribute Details

#badgeObject #badge=(badge) ⇒ Object

The message badge - not supported by all gateways

Overloads:

  • #badge=(badge) ⇒ Object

    Parameters:

    • badge (#to_s)


35
36
37
# File 'lib/pling/message.rb', line 35

def badge
  @badge
end

#bodyObject #body=(body) ⇒ Object

The message body

Overloads:

  • #body=(body) ⇒ Object

    Parameters:

    • body (#to_s)


9
10
11
# File 'lib/pling/message.rb', line 9

def body
  @body
end

#categoryObject #category=Object

The category property - not supported by all gateways



85
86
87
# File 'lib/pling/message.rb', line 85

def category
  @category
end

#content_availableObject #content_available=Object

The content_available property - not supported by all gateways



73
74
75
# File 'lib/pling/message.rb', line 73

def content_available
  @content_available
end

#payloadObject #payload=(sound) ⇒ Object

The message payload - not supported by all gateways

Overloads:

  • #payload=(sound) ⇒ Object

    Parameters:

    • payload (#to_hash)


61
62
63
# File 'lib/pling/message.rb', line 61

def payload
  @payload
end

#soundObject #sound=(sound) ⇒ Object

The message sound - not supported by all gateways

Overloads:

  • #sound=(sound) ⇒ Object

    Parameters:

    • sound (#to_s)


48
49
50
# File 'lib/pling/message.rb', line 48

def sound
  @sound
end

#subjectObject #subject=(subject) ⇒ Object

The message subject - not supported by all gateways

Overloads:

  • #subject=(subject) ⇒ Object

    Parameters:

    • subject (#to_s)


22
23
24
# File 'lib/pling/message.rb', line 22

def subject
  @subject
end

Instance Method Details

#to_pling_messagePling::Message

Returns the object itself as it is already a Pling::Message.

Returns:



128
129
130
# File 'lib/pling/message.rb', line 128

def to_pling_message
  self
end

#valid?Boolean

A message is valid if it has a body.

Returns:

  • (Boolean)


120
121
122
# File 'lib/pling/message.rb', line 120

def valid?
  !!body
end