module EVEApi::Util
Utility methods
Public Instance Methods
convert_hash_keys(value)
click to toggle source
Symbolize and underscore all Hash
keys
@param [Array, Hash] value Object
to process @return [Array, Hash] processed output
# File lib/eveapi/util.rb, line 116 def convert_hash_keys(value) case value when Array value.map { |v| convert_hash_keys(v) } when Hash Hash[value.map { |k, v| [underscore_key(k), convert_hash_keys(v)] }] else value end end
json_get(url, args = {})
click to toggle source
Make a GET request, parse JSON if present, and process the result
@param [String] url URL to Call @param [Hash] args = {} arguments passed to Excon
@return [Hash] processed result from the CREST API
# File lib/eveapi/util.rb, line 99 def json_get(url, args = {}) http = Excon.get(url, args).body convert_hash_keys(Crack::JSON.parse http) end
underscore_key(k)
click to toggle source
Make a symbolized and underscored version of a Symbol
or String
@param [String, Symbol] k Key @return [Symbol] modified version of the key
# File lib/eveapi/util.rb, line 108 def underscore_key(k) k.to_s.underscore.to_sym end