Class: Rust::Function

Inherits:
Object show all
Defined in:
lib/rust/core/types/language.rb

Overview

Represents a function call in R. After having set up its name (constructor) and, optionally, its arguments and options, it can be used the call method to execute it in the R environment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Function

Creates a new function with a given name.



121
122
123
124
125
# File 'lib/rust/core/types/language.rb', line 121

def initialize(name)
    @function = name
    @arguments  = Arguments.new
    @options    = Options.new
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



115
116
117
# File 'lib/rust/core/types/language.rb', line 115

def arguments
  @arguments
end

#nameObject (readonly)

Returns the value of attribute name.



114
115
116
# File 'lib/rust/core/types/language.rb', line 114

def name
  @name
end

#optionsObject

Returns the value of attribute options.



116
117
118
# File 'lib/rust/core/types/language.rb', line 116

def options
  @options
end

Instance Method Details

#callObject

Calls the function in the R environment.



153
154
155
# File 'lib/rust/core/types/language.rb', line 153

def call
    Rust._eval(self.to_R)
end

#to_RObject



145
146
147
148
# File 'lib/rust/core/types/language.rb', line 145

def to_R
    params = [@arguments.to_R, @options.to_R].select { |v| v != "" }.join(",")
    return "#@function(#{params})"
end