Class: Whally::VolumeDecomposer
- Inherits:
-
Object
- Object
- Whally::VolumeDecomposer
- Defined in:
- lib/whally/volume_decomposer.rb
Overview
Decompose response from WhalesAPI
Instance Method Summary collapse
-
#initialize(response) ⇒ VolumeDecomposer
constructor
A new instance of VolumeDecomposer.
- #textify ⇒ Object
- #volumes ⇒ Object
Constructor Details
#initialize(response) ⇒ VolumeDecomposer
Returns a new instance of VolumeDecomposer.
4 5 6 7 8 9 10 |
# File 'lib/whally/volume_decomposer.rb', line 4 def initialize(response) @volumes = [] response.each do |service| @volumes << service['volumes'] end @volumes.flatten! end |
Instance Method Details
#textify ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/whally/volume_decomposer.rb', line 12 def textify volumes.map do |volume| volume_yaml = volume.to_yaml volume_yaml[0..2] = '' volume_yaml.insert(1, " ") volume_yaml.insert(volume_yaml.index(":")+2, " ") volume_yaml[volume_yaml.size-1] = '' volume_yaml end.join end |
#volumes ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/whally/volume_decomposer.rb', line 23 def volumes volume_hash = [] @volumes.map do |volume| volume_key = volume['name'] if volume_key != '.' volume_hash << { volume_key.to_s => { 'driver' => volume['driver'] } } end end volume_hash end |