Class: DeviceCloud::PushNotification::Message::FileData

Inherits:
Object
  • Object
show all
Defined in:
lib/device_cloud/push_notification/message/file_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ FileData

Returns a new instance of FileData.



9
10
11
12
13
14
15
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 9

def initialize(attributes = {})
  @errors = []
  attributes.each do |name, value|
    send("#{name}=", value)
  end
  DeviceCloud.logger.warn "DeviceCloud::PushNotification::Message::FileData Invalid (#{errors.join(',')}) - #{full_path}" unless valid?
end

Instance Attribute Details

#cstIdObject

Returns the value of attribute cstId.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def cstId
  @cstId
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 7

def errors
  @errors
end

#fdArchiveObject

Returns the value of attribute fdArchive.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def fdArchive
  @fdArchive
end

#fdContentTypeObject

Returns the value of attribute fdContentType.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def fdContentType
  @fdContentType
end

#fdCreatedDateObject

Returns the value of attribute fdCreatedDate.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def fdCreatedDate
  @fdCreatedDate
end

#fdDataObject

Returns the value of attribute fdData.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def fdData
  @fdData
end

#fdLastModifiedDateObject

Returns the value of attribute fdLastModifiedDate.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def fdLastModifiedDate
  @fdLastModifiedDate
end

#fdSizeObject

Returns the value of attribute fdSize.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def fdSize
  @fdSize
end

#fdTypeObject

Returns the value of attribute fdType.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def fdType
  @fdType
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 6

def id
  @id
end

Instance Method Details

#content_typeObject



21
22
23
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 21

def content_type
  fdContentType
end

#dataObject



25
26
27
28
29
30
31
32
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 25

def data
  return false unless valid?
  @data ||= if json_data?
    JSON.parse unencoded_data
  else
    unencoded_data
  end
end

#file_nameObject



34
35
36
37
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 34

def file_name
  return '' unless id
  id['fdName']
end

#file_pathObject



39
40
41
42
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 39

def file_path
  return '' unless id
  id['fdPath']
end

#full_pathObject



17
18
19
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 17

def full_path
  file_path + file_name
end

#valid?Boolean

Returns:

  • (Boolean)


44
45
46
47
# File 'lib/device_cloud/push_notification/message/file_data.rb', line 44

def valid?
  return false if @errors.any?
  validate_content!
end