lib/turntabler/room_directory.rb
def all(options = {})
      assert_valid_keys(options, :limit, :skip, :favorites, :available_djs, :genre, :minimum_listeners, :sort)
      assert_valid_values(options[:genre], :rock, :electronic, :indie, :hiphop, :pop, :dubstep) if options[:genre]
      assert_valid_values(options[:sort], :created, :listeners, :random) if options[:sort]
      options = {
        :limit => 20,
        :skip => 0,
        :favorites => false,
        :available_djs => false,
        :minimum_listeners => 1,
        :sort => :listeners
      }.merge(options)

      constraints = []
      constraints << :favorites if options[:favorites]
      constraints << :available_djs if options[:available_djs]
      constraints << :"has_people=#{options[:minimum_listeners]}"
      if options[:genre]
        constraints << :"genre=#{options[:genre]}"
        options[:sort] = "#{options[:sort]},genre:#{options[:genre]}"
      end

      data = api('room.directory_rooms',
        :section_aware => true,
        :limit => options[:limit],
        :skip => options[:skip],
        :constraints => constraints * ',',
        :sort => options[:sort]
      )
      data['rooms'].map {|attrs| Room.new(client, attrs)}
    end
def all(options = {})
      assert_valid_keys(options, :limit, :skip, :favorites, :available_djs, :genre, :minimum_listeners, :sort)
      assert_valid_values(options[:genre], :rock, :electronic, :indie, :hiphop, :pop, :dubstep) if options[:genre]
      assert_valid_values(options[:sort], :created, :listeners, :random) if options[:sort]
      options = {
        :limit => 20,
        :skip => 0,
        :favorites => false,
        :available_djs => false,
        :minimum_listeners => 1,
        :sort => :listeners
      }.merge(options)

      constraints = []
      constraints << :favorites if options[:favorites]
      constraints << :available_djs if options[:available_djs]
      constraints << :"has_people=#{options[:minimum_listeners]}"
      if options[:genre]
        constraints << :"genre=#{options[:genre]}"
        options[:sort] = "#{options[:sort]},genre:#{options[:genre]}"
      end

      data = api('room.directory_rooms',
        :section_aware => true,
        :limit => options[:limit],
        :skip => options[:skip],
        :constraints => constraints * ',',
        :sort => options[:sort]
      )
      data['rooms'].map {|attrs| Room.new(client, attrs)}
    end
Gets the list of available rooms.

 @param [Hash] options The search options
 @option options [Fixnum] :limit (20) The total number of rooms to list
 @option options [Fixnum] :skip (0) The number of rooms to skip when loading the list
 @option options [Fixnum] :favorites (false) Whether to only include rooms marked as favorites
 @option options [Boolean] :available_djs (false) Whether to only include rooms that have dj spots available
 @option options [Symbol] :genre The genre of music being played in the room, .  Possible values are +:rock+, +:electronica+, +:indie+, +:hiphop+, +:pop+, and +:dubstep+.
 @option options [Fixnum] :minimum_listeners (1) The minimum number of listeners in the room
 @option options [Symbol] :sort (:listeners) The order to list rooms in.  Possible values are +:created+, +:listeners+, and +:random+.
 @return [Array<Turntabler::Room>]
 @raise [ArgumentError] if an invalid option or value is specified
 @raise [Turntabler::Error] if the command fails
 @example
   rooms.all                                           # => [#<Turntabler::Room ...>, ...]
   rooms.all(:favorites => true)                       # => [#<Turntabler::Room ...>, ...]
   rooms.all(:available_djs => true, :genre => :rock)  # => [#<Turntabler::Room ...>, ...]
   rooms.all(:sort => :random)                         # => [#<Turntabler::Room ...>, ...]