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() = 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 |
# File 'lib/soaring/detailer.rb', line 11 def detail url = URI.parse([:url]) req = Net::HTTP::Get.new(url.to_s) res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } if '200' != res.code $stderr.puts "Failed to connect with http error code #{res.code}" exit 1 end puts JSON.parse(res.body) if 'json' == [:format] print JSON.parse(res.body).to_yaml if 'yaml' == [:format] rescue StandardError => exception = "#{exception.class}: #{exception.message}" $stderr.puts "#{message}" exit 1 end |