Class: HopTimer::CheckPoint

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ CheckPoint

Returns a new instance of CheckPoint.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/hop_timer.rb', line 25

def initialize(name)
  name_validation(name)

  @name = name
  p_times = Process.times
  @r_time = Time.now
  @u_time = p_times.utime
  @s_time = p_times.stime
  @cu_time = p_times.cutime
  @cs_time = p_times.cstime
end

Instance Attribute Details

#cs_timeObject (readonly)

Returns the value of attribute cs_time.



23
24
25
# File 'lib/hop_timer.rb', line 23

def cs_time
  @cs_time
end

#cu_timeObject (readonly)

Returns the value of attribute cu_time.



23
24
25
# File 'lib/hop_timer.rb', line 23

def cu_time
  @cu_time
end

#nameObject (readonly)

Returns the value of attribute name.



23
24
25
# File 'lib/hop_timer.rb', line 23

def name
  @name
end

#r_timeObject (readonly)

Returns the value of attribute r_time.



23
24
25
# File 'lib/hop_timer.rb', line 23

def r_time
  @r_time
end

#s_timeObject (readonly)

Returns the value of attribute s_time.



23
24
25
# File 'lib/hop_timer.rb', line 23

def s_time
  @s_time
end

#u_timeObject (readonly)

Returns the value of attribute u_time.



23
24
25
# File 'lib/hop_timer.rb', line 23

def u_time
  @u_time
end

Instance Method Details

#-(other) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/hop_timer.rb', line 37

def -(other)
  time_diff_set = {}

  time_diff_set[:r_diff] = r_time - other.r_time
  time_diff_set[:u_diff] = u_time - other.u_time
  time_diff_set[:s_diff] = s_time - other.s_time
  time_diff_set[:cu_diff] = cu_time - other.cu_time
  time_diff_set[:cs_diff] = cs_time - other.cs_time

  time_diff_set.each { |key, val| time_diff_set[key] = val.abs }
end