Class: Woodhouse::Watchdog::Transition

Inherits:
Object
  • Object
show all
Defined in:
lib/woodhouse/watchdog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(old, new) ⇒ Transition

Returns a new instance of Transition.



67
68
69
70
# File 'lib/woodhouse/watchdog.rb', line 67

def initialize(old, new)
  @old = old
  @new = new
end

Instance Attribute Details

#newObject (readonly)

Returns the value of attribute new.



65
66
67
# File 'lib/woodhouse/watchdog.rb', line 65

def new
  @new
end

#oldObject (readonly)

Returns the value of attribute old.



65
66
67
# File 'lib/woodhouse/watchdog.rb', line 65

def old
  @old
end

Instance Method Details

#durationObject



88
89
90
# File 'lib/woodhouse/watchdog.rb', line 88

def duration
  old && new.time - old.time
end

#duration_sObject



92
93
94
# File 'lib/woodhouse/watchdog.rb', line 92

def duration_s
  duration && " (#{duration}s)"
end

#messageObject



84
85
86
# File 'lib/woodhouse/watchdog.rb', line 84

def message
  new.message
end

#nameObject



72
73
74
# File 'lib/woodhouse/watchdog.rb', line 72

def name
  "#{old_name} -> #{new_name}"
end

#new_nameObject



80
81
82
# File 'lib/woodhouse/watchdog.rb', line 80

def new_name
  new && new.name
end

#old_nameObject



76
77
78
# File 'lib/woodhouse/watchdog.rb', line 76

def old_name
  old && old.name
end

#to_sObject



96
97
98
# File 'lib/woodhouse/watchdog.rb', line 96

def to_s
  "{ #{name} } #{message}#{duration_s}"
end