Class: Nudge::CliRunner
- Inherits:
-
Object
- Object
- Nudge::CliRunner
- Defined in:
- lib/cli/runner.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#interpreter ⇒ Object
Returns the value of attribute interpreter.
-
#nudge_program ⇒ Object
Returns the value of attribute nudge_program.
-
#options ⇒ Object
Returns the value of attribute options.
-
#raw_code ⇒ Object
Returns the value of attribute raw_code.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(filename, options = {}) ⇒ CliRunner
constructor
A new instance of CliRunner.
- #run ⇒ Object
- #setup(options = {}) ⇒ Object
Constructor Details
#initialize(filename, options = {}) ⇒ CliRunner
Returns a new instance of CliRunner.
13 14 15 16 17 18 |
# File 'lib/cli/runner.rb', line 13 def initialize(filename, ={}) @filename = filename @nudge_program = NudgeProgram.new("") @options = @interpreter = Interpreter.new("",@options) end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/cli/runner.rb', line 5 def filename @filename end |
#interpreter ⇒ Object
Returns the value of attribute interpreter.
8 9 10 |
# File 'lib/cli/runner.rb', line 8 def interpreter @interpreter end |
#nudge_program ⇒ Object
Returns the value of attribute nudge_program.
7 8 9 |
# File 'lib/cli/runner.rb', line 7 def nudge_program @nudge_program end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/cli/runner.rb', line 9 def @options end |
#raw_code ⇒ Object
Returns the value of attribute raw_code.
6 7 8 |
# File 'lib/cli/runner.rb', line 6 def raw_code @raw_code end |
#result ⇒ Object
Returns the value of attribute result.
10 11 12 |
# File 'lib/cli/runner.rb', line 10 def result @result end |
Instance Method Details
#run ⇒ Object
29 30 31 |
# File 'lib/cli/runner.rb', line 29 def run return @interpreter.run end |
#setup(options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/cli/runner.rb', line 21 def setup( = {}) @raw_code = IO.open(@filename) @interpreter.reset(@raw_code) [:variables].each {|name, val| @interpreter.bind_variable(name, val)} if [:variables] [:sensors].each {|name, block| @interpreter.register_sensor(name, &block)} if [:sensors] end |