Sha256: 67de9f5523af0b167bbab5da1bad0bbabc56c0879e81b8b033aea90c42dedfaa

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

module EveOnline
  class Bookmark
    attr_reader :options

    def initialize(options = {})
      @options = options
    end

    def as_json(*args)
      {
        bookmark_id: bookmark_id,
        creator_id: creator_id,
        created: created,
        item_id: item_id,
        type_id: type_id,
        location_id: location_id,
        x: x,
        y: y,
        z: z,
        memo: memo,
        note: note
      }
    end

    def bookmark_id
      @bookmark_id ||= options.fetch('@bookmarkID').to_i
    end

    def creator_id
      @creator_id ||= options.fetch('@creatorID').to_i
    end

    def created
      @created ||= ActiveSupport::TimeZone['UTC'].parse(options.fetch('@created'))
    end

    def item_id
      @item_id ||= options.fetch('@itemID').to_i
    end

    def type_id
      @type_id ||= options.fetch('@typeID').to_i
    end

    def location_id
      @location_id ||= options.fetch('@locationID').to_i
    end

    def x
      @x ||= options.fetch('@x').to_f
    end

    def y
      @y ||= options.fetch('@y').to_f
    end

    def z
      @z ||= options.fetch('@z').to_f
    end

    def memo
      @memo ||= options.fetch('@memo')
    end

    def note
      @note ||= options.fetch('@note')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eve_online-0.7.0 lib/eve_online/bookmark.rb