Module: EOAT

Defined in:
lib/eoat.rb,
lib/eoat/zk_api.rb,
lib/eoat/eve_api.rb,
lib/eoat/request.rb,
lib/eoat/version.rb,
lib/eoat/exception.rb,
lib/eoat/result/eve_type.rb,
lib/eoat/cache/file_cache.rb,
lib/eoat/cache/none_cache.rb,
lib/eoat/cache/redis_cache.rb,
lib/eoat/cache/memcached_cache.rb

Overview

Eve Online API Toolbox (EOAT) module

Author:

Defined Under Namespace

Modules: Cache, Exception, Result Classes: EveApi, Request, ZKApi

Constant Summary collapse

VERSION =

Current gem version

'0.1.2'

Class Method Summary collapse

Class Method Details

.cacheEOAT::Cache #read

Return current cache storage class instance

Examples:

Get current cache storage

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

Returns:



27
28
29
# File 'lib/eoat.rb', line 27

def self.cache
  @cache
end

.cache=(val) ⇒ Object

Note:

Available cache classes: FileCache, MemcachedCache, NoneCache RedisCache

Define new cache store class.

Examples:

Store cache to memcached

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

Parameters:

  • val (CacheClass)


40
41
42
43
44
45
46
# 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

.headersHash #read

This method allows to control the request headers

Examples:

Get current headers

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

Set 'From' header

EOAT.headers['From'] = '[email protected]' #=> '[email protected]'

Returns:

  • (Hash #read)

    the hash of request headers



54
55
56
# File 'lib/eoat.rb', line 54

def self.headers
  @headers
end

.max_ttlFixnum, #read

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: https://api.eveonline.com/eve/SkillTree.xml.aspx

Returns:

  • (Fixnum, #read)


64
65
66
# File 'lib/eoat.rb', line 64

def self.max_ttl
  @max_ttl
end

.max_ttl=(val) ⇒ Object

Allow set maximum TTL of cache

Parameters:

  • val (Fixnum)


70
71
72
73
74
75
76
# 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