Module: Unpatched::Utils

Extended by:
Utils
Included in:
Utils
Defined in:
lib/unpatched.rb

Instance Method Summary collapse

Instance Method Details

#numeric(value) ⇒ Object Also known as: num



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/unpatched.rb', line 22

def numeric(value)
  case value
  when Numeric then value
  when Wrapper then numeric unwrapped(value)
  else
    begin
      Integer value
    rescue ArgumentError
      Float value
    end
  end
end

#unwrapped(value) ⇒ Object



17
18
19
20
# File 'lib/unpatched.rb', line 17

def unwrapped(value)
  value = value.__instance_eval__ { @value } while Wrapper === value
  value
end

#wrapped(value) ⇒ Object



13
14
15
# File 'lib/unpatched.rb', line 13

def wrapped(value)
  NormalWrapper.new(value)
end