Exception: Rus3::Error

Inherits:
StandardError
  • Object
show all
Includes:
EmptyList
Defined in:
lib/rus3/error.rb

Constant Summary collapse

A2L_MAP =

:nodoc:

{ "[" => "(", "," => "", "]" => ")"}

Constants included from EmptyList

Rus3::EmptyList::EMPTY_LIST

Instance Method Summary collapse

Methods included from EmptyList

#null?

Instance Method Details

#smart_error_value(obj) ⇒ Object

:nodoc:



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rus3/error.rb', line 7

def smart_error_value(obj)  # :nodoc:
  case obj
  when Array
    if obj.empty?           # an empty list
      "()"
    else                    # a normal proper list
      list_notation = obj.to_s().gsub(/[\[\],]/, A2L_MAP)
      "list( %s )" % list_notation
    end
  when Numeric
    "number(%d)" % obj
  when Rus3::Pair
    "pair(%s)" % obj
  when Rus3::Vector
    "vector(%s)" % obj
  else
    "%s(%s)" % [obj.class, obj]
  end
end