class HopTimer::CheckPoint
Attributes
cs_time[R]
cu_time[R]
name[R]
r_time[R]
s_time[R]
u_time[R]
Public Class Methods
new(name)
click to toggle source
# 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
Public Instance Methods
-(other)
click to toggle source
# 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
Private Instance Methods
name_validation(name)
click to toggle source
# File lib/hop_timer.rb, line 51 def name_validation(name) error_message = "Use alphanumeric and underscore characters only" invalid_name = ArgumentError.new(error_message) raise invalid_name unless valid_name?(name) end
valid_name?(name)
click to toggle source
# File lib/hop_timer.rb, line 57 def valid_name?(name) name == name.gsub(/[^a-z0-9_]/, '') end