Class: Rust::Plots::GGPlot::Theme::Element

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

Direct Known Subclasses

BlankElement, LineElement, RectElement, TextElement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Element

Returns a new instance of Element.



87
88
89
# File 'lib/rust/external/ggplot2/themes.rb', line 87

def initialize(**options)
    @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



85
86
87
# File 'lib/rust/external/ggplot2/themes.rb', line 85

def options
  @options
end

Instance Method Details

#r_functionObject



91
92
93
# File 'lib/rust/external/ggplot2/themes.rb', line 91

def r_function
    raise "Not implemented for generic theme element"
end

#to_hObject



104
105
106
107
108
# File 'lib/rust/external/ggplot2/themes.rb', line 104

def to_h
    hash = @options.clone
    hash['_type'] = self.class.name
    return hash
end

#to_RObject



95
96
97
98
99
100
101
102
# File 'lib/rust/external/ggplot2/themes.rb', line 95

def to_R
    options = @options.map { |k, v| [k.to_s.gsub("_", "."), v] }.to_h
    
    function = Rust::Function.new(self.r_function)
    function.options = Rust::Options.from_hash(options)
    
    return function.to_R
end