Class: Rust::Plots::GGPlot::Layer

Inherits:
Object
  • Object
show all
Defined in:
lib/rust/external/ggplot2/core.rb

Direct Known Subclasses

FlipCoordinates, Geom, Labels, Theme

Instance Method Summary collapse

Constructor Details

#initialize(function_name, **options) ⇒ Layer

Returns a new instance of Layer.



15
16
17
18
19
# File 'lib/rust/external/ggplot2/core.rb', line 15

def initialize(function_name, **options)
    @function_name = function_name
    @arguments = Rust::Arguments.new
    @options = Rust::Options.from_hash(options)
end

Instance Method Details

#option(key, value) ⇒ Object



21
22
23
# File 'lib/rust/external/ggplot2/core.rb', line 21

def option(key, value)
    @options[key] = value
end

#to_RObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rust/external/ggplot2/core.rb', line 25

def to_R
    if !block_given?
        options, arguments = @options, @arguments
    else
        options, arguments = yield(@options, @arguments)
    end
    
    options = Rust::Options.from_hash(options) unless options.is_a?(Rust::Options)
    
    function = Rust::Function.new(@function_name)
    function.arguments = arguments if arguments
    function.options = options if options
    return function.to_R
end