Class: DeviceCloud::PushNotification::Message
- Inherits:
-
Object
- Object
- DeviceCloud::PushNotification::Message
- Defined in:
- lib/device_cloud/push_notification/message.rb
Defined Under Namespace
Classes: FileData
Constant Summary collapse
- KNOWN_TOPICS =
%w{ event data alert }
Instance Attribute Summary collapse
-
#file_data ⇒ Object
Returns the value of attribute file_data.
-
#group ⇒ Object
Returns the value of attribute group.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#replay ⇒ Object
Returns the value of attribute replay.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#topic ⇒ Object
Returns the value of attribute topic.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Message
constructor
A new instance of Message.
- #no_content? ⇒ Boolean
- #parsed_file_data ⇒ Object
- #topic_type ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Message
Returns a new instance of Message.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/device_cloud/push_notification/message.rb', line 16 def initialize(attributes = {}) attributes.each do |name, value| if name == 'FileData' @file_data = value else send("#{name}=", value) end end DeviceCloud.logger.info "DeviceCloud::PushNotification::Message Invalid (no FileData) - #{topic}" unless valid? end |
Instance Attribute Details
#file_data ⇒ Object
Returns the value of attribute file_data.
3 4 5 |
# File 'lib/device_cloud/push_notification/message.rb', line 3 def file_data @file_data end |
#group ⇒ Object
Returns the value of attribute group.
3 4 5 |
# File 'lib/device_cloud/push_notification/message.rb', line 3 def group @group end |
#operation ⇒ Object
Returns the value of attribute operation.
3 4 5 |
# File 'lib/device_cloud/push_notification/message.rb', line 3 def operation @operation end |
#replay ⇒ Object
Returns the value of attribute replay.
3 4 5 |
# File 'lib/device_cloud/push_notification/message.rb', line 3 def replay @replay end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/device_cloud/push_notification/message.rb', line 3 def @timestamp end |
#topic ⇒ Object
Returns the value of attribute topic.
3 4 5 |
# File 'lib/device_cloud/push_notification/message.rb', line 3 def topic @topic end |
Class Method Details
.parse_raw_messages(raw_message_data) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/device_cloud/push_notification/message.rb', line 7 def self.() if .is_a? Array = .map {|| new() } else = [new()] end end |
Instance Method Details
#no_content? ⇒ Boolean
36 37 38 |
# File 'lib/device_cloud/push_notification/message.rb', line 36 def no_content? parsed_file_data.no_content? end |
#parsed_file_data ⇒ Object
31 32 33 34 |
# File 'lib/device_cloud/push_notification/message.rb', line 31 def parsed_file_data return false unless valid? @parsed_file_data ||= FileData.new file_data end |
#topic_type ⇒ Object
27 28 29 |
# File 'lib/device_cloud/push_notification/message.rb', line 27 def topic_type topic_matches.first end |
#valid? ⇒ Boolean
40 41 42 |
# File 'lib/device_cloud/push_notification/message.rb', line 40 def valid? !!file_data end |