Class: Soaring::Detailer
- Inherits:
-
Object
- Object
- Soaring::Detailer
- Defined in:
- lib/soaring/detailer.rb
Instance Method Summary collapse
- #detail ⇒ Object
-
#initialize(options) ⇒ Detailer
constructor
A new instance of Detailer.
Constructor Details
#initialize(options) ⇒ Detailer
Returns a new instance of Detailer.
7 8 9 |
# File 'lib/soaring/detailer.rb', line 7 def initialize() @options = end |
Instance Method Details
#detail ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/soaring/detailer.rb', line 11 def detail uri = URI.parse(@options[:url]) args = {} uri.query = URI.encode_www_form(args) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.is_a?(URI::HTTPS) request = Net::HTTP::Get.new(uri.request_uri) response = http.request(request) if '200' != response.code $stderr.puts "Failed to connect with http error code #{response.code}" exit 1 end puts JSON.parse(response.body) if 'json' == @options[:format] print JSON.parse(response.body).to_yaml if 'yaml' == @options[:format] rescue StandardError => exception = "#{exception.class}: #{exception.}" $stderr.puts "#{}" exit 1 end |