Class: Object

Inherits:
BasicObject
Defined in:
lib/nose/util.rb,
lib/nose/util.rb

Overview

Add simple convenience methods

Instance Method Summary collapse

Instance Method Details

#deep_symbolize_keysObject

Convert all the keys of a hash to symbols

Returns:



200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/nose/util.rb', line 200

def deep_symbolize_keys
  return each_with_object({}) do |(k, v), memo|
    memo[k.to_sym] = v.deep_symbolize_keys
    memo
  end if is_a? Hash

  return each_with_object([]) do |v, memo|
    memo << v.deep_symbolize_keys
    memo
  end if is_a? Array

  self
end

#inspectObject



68
69
70
# File 'lib/nose/util.rb', line 68

def inspect
  Formatador.parse(respond_to?(:to_color) ? to_color : to_s)
end

#to_colorString

Get a colored representation of the object

Returns:

  • (String)


74
75
76
# File 'lib/nose/util.rb', line 74

def to_color
  to_s
end