Class: Ichabod::ScriptObject::Ruby
- Inherits:
-
Object
- Object
- Ichabod::ScriptObject::Ruby
- Defined in:
- lib/ichabod/script_object/ruby.rb
Instance Attribute Summary collapse
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
Instance Method Summary collapse
-
#initialize(runtime) ⇒ Ruby
constructor
A new instance of Ruby.
-
#invokeDefaultMethodWithArguments(args) ⇒ Object
Ruby(‘$LOAD_PATH’) => array…
-
#invokeUndefinedMethodFromWebScript(name, withArguments: args) ⇒ Object
Lets us call simple ruby methods.
Constructor Details
#initialize(runtime) ⇒ Ruby
Returns a new instance of Ruby.
6 7 8 |
# File 'lib/ichabod/script_object/ruby.rb', line 6 def initialize(runtime) @runtime = runtime end |
Instance Attribute Details
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
4 5 6 |
# File 'lib/ichabod/script_object/ruby.rb', line 4 def runtime @runtime end |
Instance Method Details
#invokeDefaultMethodWithArguments(args) ⇒ Object
Ruby(‘$LOAD_PATH’) => array… Ruby(‘1 + 1’) => 2
38 39 40 |
# File 'lib/ichabod/script_object/ruby.rb', line 38 def invokeDefaultMethodWithArguments(args) eval(args[0]) end |
#invokeUndefinedMethodFromWebScript(name, withArguments: args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ichabod/script_object/ruby.rb', line 16 def invokeUndefinedMethodFromWebScript(name, withArguments:args) if respond_to? name send(name, *args) elsif Kernel.respond_to? name Kernel.send(name, *args) elsif name =~ /^([A-Z][A-Za-z]+)_(.+)/ const = Kernel.const_get($1) method = $2 if const.respond_to? method const.send(method, *args) elsif const.respond_to?("#{method}?") const.send("#{method}?", *args) elsif const.respond_to?("#{method}!") const.send("#{method}!", *args) end end end |