Class: PRX::Model::AudioFile

Inherits:
Base
  • Object
show all
Includes:
Representer::Full::AudioFileRepresenter, Roar::Representer::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.



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

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

Instance Attribute Details

#attach_fileObject

Returns the value of attribute attach_file.



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

def attach_file
  @attach_file
end

#content_typeObject

Returns the value of attribute content_type.



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

def content_type
  @content_type
end

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

#lengthObject

Returns the value of attribute length.



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

def length
  @length
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#prepare_file_uploadObject



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

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