Sha256: e30b8413a4796045c29f9f38e7a72334beba4e43522da1ffef5c501871f10d6f

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require 'vk/exceptions'
require 'vk/audio'

module Vk
  module DSL
    module Audio
      AUDIO_SORT = {
        popularity: 2,
        duration: 1,
        date: 0
      }

      # @param [Integer] owner_id user’s identifier
      # @param [Hash] options
      # @option options [Fixnum] :offset
      # @option options [Fixnum] :count
      def get_audios(owner_id, options = {})
        fail NotImplementedError, ':need_user is not supported for audio.get method' if options.key?(:need_user)
        Vk::Result.new('audio.get', Vk::Audio, options.merge(owner_id: owner_id))
      end

      # @param [Integer] owner_id user’s identifier
      # @param [Hash] options
      # @option options [Fixnum] :offset
      # @option options [Fixnum] :count
      def get_audio_albums(owner_id, options = {})
        Vk::Result.new('audio.getAlbums', Vk::Audio::Album, options.merge(owner_id: owner_id))
      end

      # @param [Fixnum] lyrics_id
      # @return [Vk::Audio::Lyrics]
      def get_lyrics(lyrics_id)
        Vk::Audio::Lyrics.new(request('audio.getLyrics', {lyrics_id: lyrics_id}))
      end

      # @param [String] q
      # @param [Hash] options
      # @option options [Fixnum] :offset
      # @option options [Fixnum] :count
      # @option options [Fixnum] :auto_complete
      def search_lyrics(q, options = {})
        options[:auto_complete] = !!options[:auto_complete] ? 1 : 0 if options.key?(:auto_complete)
        options[:lyrics] = !!options[:lyrics] ? 1 : 0 if options.key?(:lyrics)
        options[:performer_only] = !!options[:performer_only] ? 1 : 0 if options.key?(:performer_only)
        options[:sort] = AUDIO_SORT[options[:sort]] if options[:sort].is_a?(Symbol)
        options[:search_own] = !!options[:search_own] ? 1 : 0 if options.key?(:search_own)
        Vk::Result.new('audio.search', Vk::Audio, options.merge(q: q))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vk-0.6.5.53 lib/vk/dsl/audio.rb