Sha256: 632271752046e2e1bc1f1fc9ef99495aa8474b56b1e368d84a478df1027535ca

Contents?: true

Size: 892 Bytes

Versions: 7

Compression:

Stored size: 892 Bytes

Contents

module Songkickr
  # A class to represent the result hash of an Setlist search.
  #
  # http://www.songkick.com/developer/setlists
  class ConcertSetlistResult
    attr_accessor :results
    
    # Takes the result ash and passes it to parse_results
    def initialize(result_hash = {})
      if result_hash["resultsPage"]
        results_page = result_hash["resultsPage"]
      
        if results_page
          @results = parse_results results_page["results"]
        end
      else
        result_hash
      end
    end
    
    
    protected
      
      # Parses the setlist items into an array of SetlistItems
      def parse_results(results = {})
        setlists = []
        if results.include?("setlist")
          results["setlist"].each do |setlist|
            setlists << Songkickr::Setlist.new(setlist)
          end
        end
        
        setlists
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
songkickr-0.3.3 lib/songkickr/concert_setlist_result.rb
songkickr-0.3.2 lib/songkickr/concert_setlist_result.rb
songkickr-0.3.1 lib/songkickr/concert_setlist_result.rb
songkickr-0.3.0 lib/songkickr/concert_setlist_result.rb
songkickr-0.2.2 lib/songkickr/concert_setlist_result.rb
songkickr-0.2.1 lib/songkickr/concert_setlist_result.rb
songkickr-0.2.0 lib/songkickr/concert_setlist_result.rb