Sha256: 3233841d148545782d515fd0104daa1dac581ae4d329a3f206def6883fd7d767

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

module EveOnline
  module XML
    # https://eveonline-third-party-documentation.readthedocs.org/en/latest/xmlapi/character/char_upcomingcalendarevents.html
    class CharacterUpcomingCalendarEvents < Base
      API_ENDPOINT = 'https://api.eveonline.com/char/UpcomingCalendarEvents.xml.aspx'.freeze

      ACCESS_MASK = 1_048_576

      attr_reader :key_id, :v_code, :character_id

      def initialize(key_id, v_code, character_id)
        super()
        @key_id = key_id
        @v_code = v_code
        @character_id = character_id
      end

      def events
        case row
        when Hash
          [Event.new(row)]
        when Array
          output = []
          row.each do |event|
            output << Event.new(event)
          end
          output
        else
          raise ArgumentError
        end
      end
      memoize :events

      def url
        "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }&characterID=#{ character_id }"
      end

      private

      def rowset
        result.fetch('rowset')
      end
      memoize :rowset

      def row
        rowset.fetch('row')
      end
      memoize :row
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eve_online-0.14.0 lib/eve_online/xml/character_upcoming_calendar_events.rb
eve_online-0.13.0 lib/eve_online/xml/character_upcoming_calendar_events.rb
eve_online-0.12.0 lib/eve_online/xml/character_upcoming_calendar_events.rb