Class: SymbolExprString

Inherits:
Object
  • Object
show all
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

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_sObject Also known as: to_expr_str



15
16
17
# File 'lib/R_interface/ruby_extensions.rb', line 15

def to_s
  @str
end