module EOAT

Eve Online API Toolbox (EOAT) module @author Ivan Kotov {i.s.kotov.ws e-mail}

Constants

VERSION

Current gem version

Public Class Methods

cache() click to toggle source

Return current cache storage class instance @example Get current cache storage

EOAT.cache #=> #<EOAT::Cache::NoneCache:0x007ff97a8b6bd8>

@return [EOAT::Cache read] the instance of cache class

# File lib/eoat.rb, line 27
def self.cache
  @cache
end
cache=(val) click to toggle source

Define new cache store class. @note Available cache classes:

{EOAT::Cache::FileCache FileCache},
{EOAT::Cache::MemcachedCache MemcachedCache},
{EOAT::Cache::NoneCache NoneCache}
{EOAT::Cache::RedisCache RedisCache}

@example Store cache to memcached

EOAT.cache = EOAT::Cache::MemcachedCache.new

@param [CacheClass] val

# File lib/eoat.rb, line 40
def self.cache=(val)
  if EOAT::Cache.constants.include? val.class.name.split('::').last.to_sym
    @cache = val
  else
    raise TypeError, "Wrong cache class #{val.class}"
  end
end
headers() click to toggle source

This method allows to control the request headers @example Get current headers

EOAT.headers #=> {"User-Agent"=>"EOAT/0.0.1 (Eve Online Api Toolbox;+https://github.com/elDante/eoat)"}

@example Set ‘From’ header

EOAT.headers['From'] = 'user@example.com' #=> 'user@example.com'

@return [Hash read] the hash of request headers

# File lib/eoat.rb, line 54
def self.headers
  @headers
end
max_ttl() click to toggle source

Return a current maximum TTL of cache in seconds By default: 30 days. Has been introduced to support the memcached. Since the TTL is calculated from the cached_until - request_time, and it may be ~ 10 years. Example: api.eveonline.com/eve/SkillTree.xml.aspx @return [Fixnum, read]

# File lib/eoat.rb, line 64
def self.max_ttl
  @max_ttl
end
max_ttl=(val) click to toggle source

Allow set maximum TTL of cache @param [Fixnum] val

# File lib/eoat.rb, line 70
def self.max_ttl=(val)
  if val.class == Fixnum
    @max_ttl = val
  else
    raise TypeError, "Wrong class #{val.class} of value, it should be Fixnum"
  end
end