class DeviceCloud::PushNotification::Message::FileData
Attributes
cstId[RW]
fdArchive[RW]
fdContentType[RW]
fdCreatedDate[RW]
fdData[RW]
fdLastModifiedDate[RW]
fdSize[RW]
fdType[RW]
id[RW]
no_content[R]
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 9 def initialize(attributes = {}) @no_content = false attributes.each do |name, value| send("#{name}=", value) end validate_content! end
Public Instance Methods
content?()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 47 def content? !no_content? end
content_type()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 21 def content_type fdContentType end
data()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 25 def data @data ||= if json_data? && content? JSON.parse unencoded_data else unencoded_data end end
file_name()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 33 def file_name return '' unless id && id['fdName'] id['fdName'] end
file_path()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 38 def file_path return '' unless id && id['fdPath'] id['fdPath'] end
full_path()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 17 def full_path file_path + file_name end
no_content?()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 43 def no_content? @no_content end
Private Instance Methods
json_data?()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 51 def json_data? fdContentType =~ /json/ || file_name =~ /\.json\z/ end
unencoded_data()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 55 def unencoded_data @unencoded_data ||= no_content? ? '' : Base64.decode64(fdData) end
validate_content!()
click to toggle source
# File lib/device_cloud/push_notification/message/file_data.rb, line 59 def validate_content! @no_content = !fdData || fdData.size == 0 || fdSize.to_i < 1 end