Class: Ruboty::Tryruby::Evaluator
- Inherits:
-
Object
- Object
- Ruboty::Tryruby::Evaluator
- Defined in:
- lib/ruboty/tryruby/evaluator.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(command) ⇒ Evaluator
constructor
A new instance of Evaluator.
Constructor Details
#initialize(command) ⇒ Evaluator
Returns a new instance of Evaluator.
8 9 10 11 12 |
# File 'lib/ruboty/tryruby/evaluator.rb', line 8 def initialize(command) @http = Net::HTTP.new('tryruby.org', 80) @request = Net::HTTP::Put.new('/levels/1/challenges/0') @request.set_form_data(cmd: command) end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
6 7 8 |
# File 'lib/ruboty/tryruby/evaluator.rb', line 6 def http @http end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/ruboty/tryruby/evaluator.rb', line 6 def request @request end |
Instance Method Details
#evaluate ⇒ Object
14 15 16 17 |
# File 'lib/ruboty/tryruby/evaluator.rb', line 14 def evaluate response = http.request(request) parse(response) end |