Class: Bandwidth::Media

Inherits:
BaseModel show all
Defined in:
lib/bandwidth/messaging_lib/messaging/models/media.rb

Overview

Media Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(content = nil, content_length = nil, media_name = nil) ⇒ Media

Returns a new instance of Media.



30
31
32
33
34
35
36
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 30

def initialize(content = nil,
               content_length = nil,
               media_name = nil)
  @content = content
  @content_length = content_length
  @media_name = media_name
end

Instance Attribute Details

#contentString

TODO: Write general description for this method

Returns:

  • (String)


11
12
13
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 11

def content
  @content
end

#content_lengthInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 15

def content_length
  @content_length
end

#media_nameString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 19

def media_name
  @media_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 39

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  content = hash['content']
  content_length = hash['contentLength']
  media_name = hash['mediaName']

  # Create object from extracted values.
  Media.new(content,
            content_length,
            media_name)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
28
# File 'lib/bandwidth/messaging_lib/messaging/models/media.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['content'] = 'content'
  @_hash['content_length'] = 'contentLength'
  @_hash['media_name'] = 'mediaName'
  @_hash
end