Class: Rust::Plots::GGPlot::ThemeComponentBuilder
- Inherits:
-
Object
- Object
- Rust::Plots::GGPlot::ThemeComponentBuilder
show all
- Defined in:
- lib/rust/external/ggplot2/themes.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ThemeComponentBuilder.
136
137
138
139
|
# File 'lib/rust/external/ggplot2/themes.rb', line 136
def initialize(namespace=nil)
@namespace = namespace
@options = {}
end
|
Instance Method Details
148
149
150
151
|
# File 'lib/rust/external/ggplot2/themes.rb', line 148
def [](key)
key = "#@namespace.#{key}" if @namespace
return @options[key]
end
|
#alignment_el(value) ⇒ Object
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/rust/external/ggplot2/themes.rb', line 211
def alignment_el(value)
if value.is_a?(String) || value.is_a?(Symbol)
case value.to_s.downcase
when 'left'
value = 1
when 'right'
value = 0
else
value = 1
end
end
return value
end
|
231
232
233
|
# File 'lib/rust/external/ggplot2/themes.rb', line 231
def build
@options
end
|
#numeric_el(value) ⇒ Object
226
227
228
229
|
# File 'lib/rust/external/ggplot2/themes.rb', line 226
def numeric_el(value)
raise "Expected number" unless value.is_a?(Numeric)
return value
end
|
#option(key, value) ⇒ Object
141
142
143
144
145
146
|
# File 'lib/rust/external/ggplot2/themes.rb', line 141
def option(key, value)
key = "#@namespace.#{key}" if @namespace
@options[key] = value
return self
end
|
#unit_el(value) ⇒ Object
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/rust/external/ggplot2/themes.rb', line 189
def unit_el(value)
numeric = nil
unit = nil
if input.is_a?(String)
numeric, unit = *input.scan(/^([0-9.]+)([A-Za-z]+)/).flatten
raise "Unclear numeric part in #{input}" unless numeric
raise "Unclear unit part in #{input}" unless unit
elsif input.is_a?(Numeric)
numeric = input
unit = "npc"
end
raise "Unable to handle #{input}" unless numeric && unit
function = Rust::Function.new("units")
function.arguments = Rust::Arguments.new([numeric, unit])
return function.to_R
end
|