Module: Wicket::Utilities

Defined in:
lib/wicket/utilities.rb

Class Method Summary collapse

Class Method Details

.format(n, opts = {}) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/wicket/utilities.rb', line 22

def format(n,opts={})
  s = scale(opts)
  if s == 0 
    n.to_i.to_s
  else
    n.round(s).to_s("F")
  end
end

.radians_tolerance(opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/wicket/utilities.rb', line 4

def radians_tolerance(opts={})
  t = opts[:min_angle]
  case opts[:min_angle_unit] || determine_tolerance(t)
  when nil,:radians 
    check_range(Math::PI,t)
    t
  when :degrees
    check_range(180,t)
    (t / 180.0) * Math::PI
  when :percentage
    check_range(100,t)
    (t / 100.0) * Math::PI
  when :decimal_percentage
    check_range(1,t)
    t * Math::PI
  end
end