Class: PassengerReaper::PsEtime

Inherits:
Object
  • Object
show all
Defined in:
lib/passenger_reaper/ps_etime.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_etime) ⇒ PsEtime

Returns a new instance of PsEtime.



6
7
8
9
10
11
12
13
# File 'lib/passenger_reaper/ps_etime.rb', line 6

def initialize(raw_etime)
  @etime = raw_etime
  split_etime = @etime.split(/\-|\:/).map {|a| a.to_i}
  @seconds = split_etime[-1] || 0
  @minutes = split_etime[-2] || 0 
  @hours = split_etime[-3] || 0
  @days = split_etime[-4] || 0
end

Instance Attribute Details

#daysObject

Returns the value of attribute days.



3
4
5
# File 'lib/passenger_reaper/ps_etime.rb', line 3

def days
  @days
end

#etimeObject (readonly)

Returns the value of attribute etime.



4
5
6
# File 'lib/passenger_reaper/ps_etime.rb', line 4

def etime
  @etime
end

#hoursObject

Returns the value of attribute hours.



3
4
5
# File 'lib/passenger_reaper/ps_etime.rb', line 3

def hours
  @hours
end

#minutesObject

Returns the value of attribute minutes.



3
4
5
# File 'lib/passenger_reaper/ps_etime.rb', line 3

def minutes
  @minutes
end

#secondsObject

Returns the value of attribute seconds.



3
4
5
# File 'lib/passenger_reaper/ps_etime.rb', line 3

def seconds
  @seconds
end

Instance Method Details

#age_in_secondsObject



15
16
17
# File 'lib/passenger_reaper/ps_etime.rb', line 15

def age_in_seconds
  @seconds + (@minutes*60) + (@hours*3600) + (@days*86400)
end