Method: Types::RplComplex.can_parse?

Defined in:
lib/rpl/types/complex.rb

.can_parse?(value) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.can_parse?( value )
  # we systematicalyl trim enclosing ()
  value = value[1..-2] if value.is_a?( String ) && value[0] == '(' && value[-1] == ')'

  begin
    Complex( value )
  rescue ArgumentError
    return false
  end

  true
end