class PortaText::Command::Api::Sounds

The sounds endpoint. github.com/PortaText/docs/wiki/REST-API#api_sounds

Author

Marcelo Gornstein (marcelog@portatext.com)

Copyright

Copyright © 2015 PortaText

License

Apache-2.0

Public Instance Methods

body(_method) click to toggle source
Calls superclass method
# File lib/portatext/command/api/sounds.rb, line 31
def body(_method)
  return "file:#{@args[:sound_file]}" unless @args[:sound_file].nil?
  super
end
description(description) click to toggle source
# File lib/portatext/command/api/sounds.rb, line 19
def description(description)
  set :description, description
end
endpoint(_method) click to toggle source

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize

# File lib/portatext/command/api/sounds.rb, line 38
def endpoint(_method)
  endpoint = 'sounds'
  id = @args[:id]
  @args.delete :id

  endpoint = "#{endpoint}/#{id}" unless id.nil?

  qs = {}
  unless @args[:description].nil?
    qs['description'] = @args[:description]
    @args.delete :description
  end

  unless @args[:name].nil?
    qs['name'] = @args[:name]
    @args.delete :name
  end

  unless qs.empty?
    qs = URI.encode_www_form qs
    return "#{endpoint}?#{qs}"
  end
  endpoint
end
id(id) click to toggle source
# File lib/portatext/command/api/sounds.rb, line 11
def id(id)
  set :id, id
end
name(name) click to toggle source
# File lib/portatext/command/api/sounds.rb, line 15
def name(name)
  set :name, name
end
save_to(file) click to toggle source
# File lib/portatext/command/api/sounds.rb, line 23
def save_to(file)
  set :accept_sound_file, file
end
sound(file) click to toggle source
# File lib/portatext/command/api/sounds.rb, line 27
def sound(file)
  set :sound_file, file
end