Class: R::Language

Inherits:
Object show all
Includes:
BinaryOperators, ExpBinOp, IndexedObject, LogicalOperators
Defined in:
lib/R_interface/rlanguage.rb

Constant Summary

Constants inherited from Object

Object::EXPLICIT_RUBY_SURFACE

Instance Attribute Summary collapse

Attributes inherited from Object

#r_interop

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IndexedObject

#[], #[]=, #size

Methods included from ExpBinOp

#assign, #coerce, #exec_bin_oper, #inter

Methods included from LogicalOperators

#&, #|

Methods included from BinaryOperators

#!=, #%, #*, #**, #+, #-, #/, #<, #<=, #>, #>=, #_, #eq, #int_div, #til

Methods inherited from Object

#==, build_class_probe_count, build_from_r_class_string, build_from_wrapper_tag, #call, class_probe_fetch_r_class, increment_build_class_probe_count!, #initialize, #inspect, #instance_of?, #instance_variable_get, #instance_variable_set, #is_a?, #method_missing, #nil?, #pretty_print, #rclass, reset_build_counters!, #respond_to?, #send, #to_ary, #to_i, #to_ruby, #typeof, #unboxed_get

Methods included from ExecUniOp

#exec_uni_oper

Methods included from UnaryOperators

#!, #+@, #-@

Methods included from ExecBinOp

#coerce, #exec_bin_oper

Constructor Details

This class inherits a constructor from R::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class R::Object

Instance Attribute Details

#expressionObject

Returns the value of attribute expression.



13
14
15
# File 'lib/R_interface/rlanguage.rb', line 13

def expression
  @expression
end

Class Method Details

.build(function_name, *args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/R_interface/rlanguage.rb', line 15

def self.build(function_name, *args)
  # function_name is something like '`+`' or '`~`'
  op = function_name.delete("`").strip
  lhs = ::R::Support.parse_arg(args[0])
  rhs = ::R::Support.parse_arg(args[1])
  r_expr = (op == ":") ? "#{lhs}#{op}#{rhs}" : "#{lhs} #{op} #{rhs}"
  lhs_display = ::R::Support.expression_display_arg(args[0])
  rhs_display = ::R::Support.expression_display_arg(args[1])
  expr_display = (op == ":") ? "#{lhs_display}#{op}#{rhs_display}" : "#{lhs_display} #{op} #{rhs_display}"
  res = ::R::Language.allocate
  res.instance_variable_set(:@r_interop, r_expr)
  res.expression = expr_display
  res
end

Instance Method Details

#classObject



9
10
11
# File 'lib/R_interface/rlanguage.rb', line 9

def class
  ::R::Language
end

#iObject



30
31
32
# File 'lib/R_interface/rlanguage.rb', line 30

def i
  "I(#{expression})"
end

#to_sObject



34
35
36
# File 'lib/R_interface/rlanguage.rb', line 34

def to_s
  expression || super
end