Class: Mocha::PrettyParameters
Instance Method Summary collapse
-
#initialize(params) ⇒ PrettyParameters
constructor
A new instance of PrettyParameters.
- #pretty ⇒ Object
- #remove_outer_array_braces! ⇒ Object
- #remove_outer_hash_braces! ⇒ Object
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
#pretty ⇒ Object
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 |