Class: Audiobank::Documents
- Inherits:
-
Object
- Object
- Audiobank::Documents
- Defined in:
- lib/audiobank/documents.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
Instance Method Summary collapse
- #create(attributes) ⇒ Object
- #import(file, attributes = {}, options = {}) ⇒ Object
-
#initialize(account) ⇒ Documents
constructor
A new instance of Documents.
Constructor Details
#initialize(account) ⇒ Documents
Returns a new instance of Documents.
5 6 7 |
# File 'lib/audiobank/documents.rb', line 5 def initialize(account) @account = account end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
3 4 5 |
# File 'lib/audiobank/documents.rb', line 3 def account @account end |
Instance Method Details
#create(attributes) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/audiobank/documents.rb', line 11 def create(attributes) Audiobank::Client.logger.debug "Create AudioBank document : #{attributes.inspect}" post "/documents.json", :document => attributes do |response| Audiobank::Document.new(response).tap do |document| document.account = account Audiobank::Client.logger.debug "Created document has id #{document.id}" end end end |
#import(file, attributes = {}, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/audiobank/documents.rb', line 21 def import(file, attributes = {}, = {}) attributes = { :title => File.basename(file, File.extname(file)), :description => "Uploaded at #{Time.now}" }.merge(attributes) create(attributes).import(file, ) end |