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.



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

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

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



82
83
84
# File 'lib/rust/external/ggplot2/themes.rb', line 82

def options
  @options
end

Instance Method Details

#r_functionObject



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

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

#to_hObject



101
102
103
104
105
# File 'lib/rust/external/ggplot2/themes.rb', line 101

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

#to_RObject



92
93
94
95
96
97
98
99
# File 'lib/rust/external/ggplot2/themes.rb', line 92

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