Module: Kernel
- Defined in:
- lib/axpert_commands.rb
Overview
This is hacky but it is really a must for accurate parsing
Instance Method Summary collapse
-
#Boolean(input) ⇒ Object
:nodoc:.
Instance Method Details
#Boolean(input) ⇒ Object
:nodoc:
533 534 535 536 537 538 539 540 541 542 |
# File 'lib/axpert_commands.rb', line 533 def Boolean(input) # :nodoc: return true if input.equal?(TrueClass) return false if input.equal?(FalseClass) parse = input.to_s.chomp.downcase return true if ('true' == parse) || ('y' == parse) || ('t' == parse) || (1 == (Integer(parse) rescue nil)) return false if ('false' == parse) || ('n' == parse) || ('f' == parse) || (0 == (Integer(parse) rescue nil)) raise rescue StandardError, ScriptError raise ::ArgumentError.new("invalid value for Boolean(): \"#{input}\"") end |