Class: Mocha::PrettyParameters

Inherits:
Object
  • Object
show all
Defined in:
lib/mocha/pretty_parameters.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ PrettyParameters

Returns a new instance of PrettyParameters.



7
8
9
10
# File 'lib/mocha/pretty_parameters.rb', line 7

def initialize(params)
  @params = params
  @params_string = params.mocha_inspect
end

Instance Method Details

#prettyObject



12
13
14
15
16
# File 'lib/mocha/pretty_parameters.rb', line 12

def pretty
  remove_outer_array_braces!
  remove_outer_hash_braces!
  @params_string
end

#remove_outer_array_braces!Object



18
19
20
# File 'lib/mocha/pretty_parameters.rb', line 18

def remove_outer_array_braces!
  @params_string = @params_string.gsub(/^\[|\]$/, '')
end

#remove_outer_hash_braces!Object



22
23
24
# File 'lib/mocha/pretty_parameters.rb', line 22

def remove_outer_hash_braces!
  @params_string = @params_string.gsub(/^\{|\}$/, '') if @params.length == 1
end