class Opener::Webservice::InputExtractor
Extracts the KAF/text input to use from a set of input parameters.
@!attribute [r] http
@return [HTTPClient]
Attributes
http[R]
Public Class Methods
new()
click to toggle source
# File lib/opener/webservice/input_extractor.rb, line 12 def initialize @http = HTTPClient.new end
Public Instance Methods
extract(options)
click to toggle source
@param [Hash] options
@option options [String] input_url A URL to download input from. @option options [String] input The direct input to process.
@return [String]
@raise [RuntimeError] Raised when the input could not be downloaded.
# File lib/opener/webservice/input_extractor.rb, line 26 def extract(options) if options['input_url'] resp = http.get(options['input_url'], :follow_redirect => true) unless resp.ok? raise "Failed to download input from #{options['input_url']}" end input = resp.body else input = options['input'] end return input end