Sha256: 3c9df39c92e7ef0afa5c81b7ef5c588119bab8ddb0897580bc13e05016471e69

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

require 'active_support/time'

module EveOnline
  class Event
    attr_reader :options

    def initialize(options)
      @options = options
    end

    def as_json
      {
        event_id: event_id,
        owner_id: owner_id,
        owner_name: owner_name,
        event_date: event_date,
        event_title: event_title,
        duration: duration,
        importance: importance,
        response: response,
        event_text: event_text,
        owner_type_id: owner_type_id
      }
    end

    def event_id
      options.fetch('@eventID').to_i
    end

    def owner_id
      options.fetch('@ownerID').to_i
    end

    def owner_name
      options.fetch('@ownerName')
    end

    def event_date
      ActiveSupport::TimeZone['UTC'].parse(options.fetch('@eventDate'))
    end

    def event_title
      options.fetch('@eventTitle')
    end

    def duration
      options.fetch('@duration').to_i
    end

    def importance
      options.fetch('@importance').eql?('1')
    end

    def response
      EventResponseObject.new(options.fetch('@response')).value
    end

    def event_text
      options.fetch('@eventText')
    end

    def owner_type_id
      options.fetch('@ownerTypeID').to_i
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eve_online-0.14.0 lib/eve_online/event.rb
eve_online-0.13.0 lib/eve_online/event.rb
eve_online-0.12.0 lib/eve_online/event.rb
eve_online-0.11.0 lib/eve_online/event.rb
eve_online-0.10.0 lib/eve_online/event.rb
eve_online-0.9.0 lib/eve_online/event.rb