Class: RubyMaxima::Session
- Inherits:
-
Object
- Object
- RubyMaxima::Session
- Defined in:
- lib/ruby_maxima/session.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#debug ⇒ Object
Returns the value of attribute debug.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
6 7 8 9 |
# File 'lib/ruby_maxima/session.rb', line 6 def initialize @commands = [] @debug = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/ruby_maxima/session.rb', line 19 def method_missing(method, *args, &block) translated_args = args.map {|arg| translate_argument arg } @commands << "#{method}(#{translated_args.join ','});" end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
3 4 5 |
# File 'lib/ruby_maxima/session.rb', line 3 def commands @commands end |
#debug ⇒ Object
Returns the value of attribute debug.
4 5 6 |
# File 'lib/ruby_maxima/session.rb', line 4 def debug @debug end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/ruby_maxima/session.rb', line 11 def execute result = `maxima -r '#{commands.join ' '}'` puts result if @debug result.scan( /(?<=\(%o#{@commands.count}\)).*(?=\(%i\d*\))/m ).first.strip end |