Class: SymbolExprString
- Inherits:
-
Object
- Object
- SymbolExprString
- Defined in:
- lib/R_interface/ruby_extensions.rb
Overview
Ruby-only expression string builder: :a + :b => "a + b", chaining :a + :b + :c => "a + b + c". No R calls; used so R.expr(:e1 + :e2 + :e3) receives a string after Ruby evaluation.
Instance Method Summary collapse
- #+(other) ⇒ Object
-
#initialize(part) ⇒ SymbolExprString
constructor
A new instance of SymbolExprString.
- #to_s ⇒ Object (also: #to_expr_str)
Constructor Details
#initialize(part) ⇒ SymbolExprString
Returns a new instance of SymbolExprString.
6 7 8 |
# File 'lib/R_interface/ruby_extensions.rb', line 6 def initialize(part) @str = part.to_s.gsub(/__/, ".") end |
Instance Method Details
#+(other) ⇒ Object
10 11 12 13 |
# File 'lib/R_interface/ruby_extensions.rb', line 10 def +(other) other_str = other.respond_to?(:to_expr_str) ? other.to_expr_str : other.to_s.gsub(/__/, ".") SymbolExprString.new("#{@str} + #{other_str}") end |
#to_s ⇒ Object Also known as: to_expr_str
15 16 17 |
# File 'lib/R_interface/ruby_extensions.rb', line 15 def to_s @str end |