Sha256: 313f502789d2935241f9551dd605aef171bb635fdaa3a22528c115978d6b27d4

Contents?: true

Size: 722 Bytes

Versions: 7

Compression:

Stored size: 722 Bytes

Contents

module Songkickr
  class CalendarEntry
    attr_accessor :reason, :event, :created_at

    def initialize(calendar_entry_hash = {})
      @created_at = calendar_entry_hash['createdAt']
      @event      = Event.new calendar_entry_hash['event']
      @reason     = parse_reason(calendar_entry_hash['reason'])
    end

    protected

      def parse_reason(entry_reason = {})
        if entry_reason.include? 'trackedArtist'
          # trackedArtist is an array of artists
          entry_reason['trackedArtist'].map { |artist| Artist.new artist }
        elsif entry_reason.include? 'attendance'
          # attendance is a string i_might_go | im_going
          entry_reason['attendance']
        end
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
songkickr-0.5.5 lib/songkickr/calendar_entry.rb
songkickr-0.5.4 lib/songkickr/calendar_entry.rb
songkickr-0.5.3 lib/songkickr/calendar_entry.rb
songkickr-0.5.2 lib/songkickr/calendar_entry.rb
songkickr-0.5.0 lib/songkickr/calendar_entry.rb
songkickr-0.4.1 lib/songkickr/calendar_entry.rb
songkickr-0.4.0 lib/songkickr/calendar_entry.rb