Class: FormatResponse

Inherits:
Struct
  • Object
show all
Defined in:
lib/format_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



1
2
3
# File 'lib/format_response.rb', line 1

def options
  @options
end

#responseObject

Returns the value of attribute response

Returns:

  • (Object)

    the current value of response



1
2
3
# File 'lib/format_response.rb', line 1

def response
  @response
end

Class Method Details

.call(*args) ⇒ Object



3
4
5
# File 'lib/format_response.rb', line 3

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
# File 'lib/format_response.rb', line 7

def call
  formated_json = JSON.pretty_generate(response)
  if response['status'] == 500 || response['status'] == 403
    puts Rainbow(formated_json).red
    exit
  else
    puts Rainbow(formated_json).green if options[:verbose]
  end
end