Module: Seiton::Helper
Instance Method Summary collapse
- #datetime_parse(datetime) ⇒ Object
- #log ⇒ Object
- #name_tag(tags) ⇒ Object
- #process_ok? ⇒ Boolean
- #volume_ids(mappings) ⇒ Object
Instance Method Details
#datetime_parse(datetime) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/seiton/common.rb', line 18 def datetime_parse(datetime) if datetime.to_s.include?('-') Time.parse(datetime.to_s.tr('-', '/')).to_i else Time.parse(datetime).to_i end end |
#log ⇒ Object
26 27 28 |
# File 'lib/seiton/common.rb', line 26 def log Logger.new(STDOUT) end |
#name_tag(tags) ⇒ Object
30 31 32 |
# File 'lib/seiton/common.rb', line 30 def name_tag() .select { |tag| tag.value if tag.key == 'Name' }.last end |
#process_ok? ⇒ Boolean
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/seiton/common.rb', line 3 def process_ok? while true puts 'Do you want to continue? [y|n]:' response = STDIN.gets.chomp case response when /^[yY]/ log.info('Continue.') return true when /^[nN]/, /^$/ log.warn('Abort.') return false end end end |
#volume_ids(mappings) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/seiton/common.rb', line 34 def volume_ids(mappings) volume_ids = [] mappings.each do |mapping| volume_ids << mapping.ebs.volume_id unless mapping.ebs.delete_on_termination end volume_ids end |