Class: Resty::PrettyPrinter
- Inherits:
-
Object
- Object
- Resty::PrettyPrinter
- Defined in:
- lib/resty/pretty_printer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(options, params) ⇒ PrettyPrinter
constructor
A new instance of PrettyPrinter.
Constructor Details
#initialize(options, params) ⇒ PrettyPrinter
Returns a new instance of PrettyPrinter.
6 7 8 9 |
# File 'lib/resty/pretty_printer.rb', line 6 def initialize(, params) @options = @params = params end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/resty/pretty_printer.rb', line 4 def @options end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/resty/pretty_printer.rb', line 4 def params @params end |
Instance Method Details
#generate ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/resty/pretty_printer.rb', line 11 def generate if params.is_a? Hashie::Mash output = "" if verbose? output += build_line("#{request.method.upcase} #{request.url}") request.processed_headers.each { |key, value| output += build_line("#{key}: #{value}") } output += "\n" output += build_line("Response Code: #{response.code}") response.headers.each { |key, value| output += build_line("#{key}: #{value}") } else output += build_line("Response Code: #{response.code}") end output += pretty_print_response(response) else params end end |