Class: PRX::Model::AudioFile

Inherits:
Base
  • Object
show all
Includes:
Representer::Full::AudioFileRepresenter, Roar::JSON
Defined in:
lib/prx/model/audio_file.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Base

#class_path_part, #find_by_id, request, #request, #save

Constructor Details

#initialize(*args) ⇒ AudioFile

Returns a new instance of AudioFile.



29
30
31
32
33
# File 'lib/prx/model/audio_file.rb', line 29

def initialize(*args)
  self.content_type = 'audio/mpeg'
  super
  self
end

Instance Attribute Details

#attach_fileObject

Returns the value of attribute attach_file.



12
13
14
# File 'lib/prx/model/audio_file.rb', line 12

def attach_file
  @attach_file
end

#content_typeObject

Returns the value of attribute content_type.



11
12
13
# File 'lib/prx/model/audio_file.rb', line 11

def content_type
  @content_type
end

#labelObject

Returns the value of attribute label.



11
12
13
# File 'lib/prx/model/audio_file.rb', line 11

def label
  @label
end

#lengthObject

Returns the value of attribute length.



11
12
13
# File 'lib/prx/model/audio_file.rb', line 11

def length
  @length
end

#sizeObject

Returns the value of attribute size.



11
12
13
# File 'lib/prx/model/audio_file.rb', line 11

def size
  @size
end

#statusObject

Returns the value of attribute status.



11
12
13
# File 'lib/prx/model/audio_file.rb', line 11

def status
  @status
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/prx/model/audio_file.rb', line 11

def url
  @url
end

Instance Method Details

#prepare_file_uploadObject



20
21
22
23
24
25
26
27
# File 'lib/prx/model/audio_file.rb', line 20

def prepare_file_upload
  if self.attach_file && self.attach_file.is_a?(String)
    uri = URI.parse(self.attach_file)
    if uri.scheme.blank? || (uri.scheme == 'file')
      self.attach_file = Faraday::UploadIO.new(uri.path, self.content_type)
    end
  end
end