Class: Snap::VBox::SnapShot
- Inherits:
-
Object
- Object
- Snap::VBox::SnapShot
- Defined in:
- lib/vagrant_snap.rb
Overview
{{{
Constant Summary collapse
- @@snaps =
[]
Class Method Summary collapse
- ._parse(snaps, level = 0) ⇒ Object
- .is_endnode? ⇒ Boolean
- .parse_tree(vmname) ⇒ Object
- .snaps ⇒ Object
-
.time_elapse(time) ⇒ Object
- TODO
-
need refactoring.
Class Method Details
._parse(snaps, level = 0) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vagrant_snap.rb', line 39 def _parse(snaps, level=0) @@snaps << snaps.name # time = snaps.time_stamp.strftime "%m%d-%H:%M" time = time_elapse(Time.now - snaps.time_stamp) result = "#{' ' * level}+-#{snaps.name} [ #{time} ]" result << " #{snaps.description}" unless snaps.description.empty? result = result.yellow if snaps.uuid == @@current.uuid result << "\n" snaps.children.each do |e| result << _parse(e, level+1) end result end |
.is_endnode? ⇒ Boolean
8 |
# File 'lib/vagrant_snap.rb', line 8 def is_endnode?() @@current.uuid == @@snaps.last.uuid end |
.parse_tree(vmname) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/vagrant_snap.rb', line 12 def parse_tree(vmname) vm = VirtualBox::VM.find( vmname ) @@current = vm.current_snapshot return unless @@current _parse(vm.root_snapshot) end |
.snaps ⇒ Object
10 |
# File 'lib/vagrant_snap.rb', line 10 def snaps() @@snaps end |
.time_elapse(time) ⇒ Object
- TODO
-
need refactoring
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant_snap.rb', line 20 def time_elapse(time) _sec = 1 _min = _sec * 60 _hour = _min * 60 _day = _hour * 24 sec = time.to_i min = sec / _min hour = sec / _hour day = sec / _day case when day > 0 then "#{day} day#{day == 1 ? '' : 's'}" when hour > 0 then "#{hour} hour#{hour == 1 ? '' : 's'}" when min > 0 then "#{min} minute#{min == 1 ? '' : 's'}" when sec > 0 then "#{sec} second#{sec == 1 ? '' : 's'}" end end |