Class: DummyOscar::Client
- Inherits:
-
Object
- Object
- DummyOscar::Client
- Defined in:
- lib/dummy_oscar/client.rb
Instance Method Summary collapse
-
#initialize(config_file:, host:, command:, library: nil) ⇒ Client
constructor
A new instance of Client.
- #start ⇒ Object
Constructor Details
#initialize(config_file:, host:, command:, library: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 |
# File 'lib/dummy_oscar/client.rb', line 7 def initialize(config_file:, host:, command:, library: nil) raise DummyOscar::ArgumentError, "Pleaes specify command argument." if command.nil? @command = command @commands = {} @host = host parse_config_file(config_file: config_file, library: library) end |
Instance Method Details
#start ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dummy_oscar/client.rb', line 16 def start request = @commands[@command] raise DummyOscar::ArgumentError, "'#{@command}' did not find." if request.nil? = {} [:body] = request["body"] unless request["body"].nil? [:query] = request["query"] unless request["query"].nil? response = HTTParty.public_send(request["method"].downcase, URI.join(@host, request["path"]).to_s, ) $stdout.puts response.body end |