Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/eveapi/util.rb
Overview
Utility Hash methods
Instance Method Summary collapse
-
#collapse_key ⇒ Hash
Merge the value of the one and only key with the Hash.
-
#details ⇒ Hash, Array
Try to get defails on a
Hash
returned from CREST. -
#normalize_array_rowset ⇒ Hash
Cleanup not needed keys from the result.
-
#normalize_hash_rowset ⇒ Hash
Cleanup not needed keys from the result.
-
#process_rows ⇒ Hash
Process rows of API request data, normalize, symbolize.
-
#ruby_method_name ⇒ Symbol
Generate a ruby method_name from a API Call list
Hash
.
Instance Method Details
#collapse_key ⇒ Hash
Merge the value of the one and only key with the Hash
33 34 35 |
# File 'lib/eveapi/util.rb', line 33 def collapse_key length == 1 ? self.merge!(delete(keys.first)) : self end |
#details ⇒ Hash, Array
Try to get defails on a Hash
returned from CREST
6 7 8 |
# File 'lib/eveapi/util.rb', line 6 def details convert_hash_keys json_get(self[:href]) if self[:href] end |
#normalize_array_rowset ⇒ Hash
Cleanup not needed keys from the result
48 49 50 51 52 53 |
# File 'lib/eveapi/util.rb', line 48 def normalize_array_rowset self['rowset'].each do |rowset| self[rowset['name']] = rowset['row'] end delete('rowset') end |
#normalize_hash_rowset ⇒ Hash
Cleanup not needed keys from the result
40 41 42 43 |
# File 'lib/eveapi/util.rb', line 40 def normalize_hash_rowset self.merge!(self['rowset']['name'] => self['rowset']['row']) delete('rowset') end |
#process_rows ⇒ Hash
Process rows of API request data, normalize, symbolize
20 21 22 23 24 25 26 27 28 |
# File 'lib/eveapi/util.rb', line 20 def process_rows case self['rowset'] when Hash normalize_hash_rowset when Array normalize_array_rowset end collapse_key end |
#ruby_method_name ⇒ Symbol
Generate a ruby method_name from a API Call list Hash
13 14 15 |
# File 'lib/eveapi/util.rb', line 13 def ruby_method_name (self[:type][0..3].downcase + '_' + self[:name].underscore).to_sym end |