Module: Debug::DataModel::PrettyFormat

Defined in:
lib/moon/packages/debug/data_model.rb

Class Method Summary collapse

Class Method Details

.array_type(array) ⇒ Object


5
6
7
8
9
10
11
12
13
14
# File 'lib/moon/packages/debug/data_model.rb', line 5

def self.array_type(array)
  case array.size
  when 0
    "#{array.class}"
  when 1
    "#{array.class}<#{array.first}>"
  else
    "#{array.class}#{array.inspect}"
  end
end

.hash_type(hash) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/moon/packages/debug/data_model.rb', line 16

def self.hash_type(hash)
  case hash.size
  when 0
    "#{hash.class}"
  when 1
    pair = hash.first
    "#{hash.class}<#{pair[0]}, #{pair[1]}>"
  else
    "#{hash.class}#{hash.inspect}"
  end
end

.object_type(type) ⇒ Object


28
29
30
31
32
33
34
35
36
37
# File 'lib/moon/packages/debug/data_model.rb', line 28

def self.object_type(type)
  case type
  when Array
    array_type(type)
  when Hash
    hash_type(type)
  else
    type.inspect
  end
end