Module: NumTools

Included in:
Stopwatch
Defined in:
lib/walltime.rb

Overview

Author: Brian Hood

Description: Walltime

A stopwatch project for all kinds of things

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_component(name) ⇒ Object



15
16
17
18
19
20
# File 'lib/walltime.rb', line 15

def self.define_component(name)
  name_func = name.to_s.gsub("_to", "").to_sym
  define_method(name) do |val, x|  
    (val * 10**x).send("#{name_func}").to_f / 10**x
  end
end

Instance Method Details

#random_between(min, max) ⇒ Object



13
# File 'lib/walltime.rb', line 13

def random_between(min, max); min+rand(max); end