class MiniHistogram::PlotValue
This is an object that holds a histogram and it's corresponding plot options
Example:
x = PlotValue.new x.values = [1,2,3,4,5] x.options = {xlabel: "random"} x.plot # => Generates a histogram plot with these values and options
Attributes
histogram[RW]
options[RW]
Public Class Methods
dual_plot(plot_a, plot_b)
click to toggle source
# File lib/mini_histogram/plot.rb, line 49 def self.dual_plot(plot_a, plot_b) a_lines = plot_a.to_s.lines b_lines = plot_b.to_s.lines max_length = a_lines.map(&:length).max side_by_side = String.new("") a_lines.each_index do |i| side_by_side << a_lines[i].chomp.ljust(max_length) # Remove newline, ensure same length side_by_side << b_lines[i] end return side_by_side end
new()
click to toggle source
# File lib/mini_histogram/plot.rb, line 34 def initialize @histogram = nil @options = {} end
Public Instance Methods
plot()
click to toggle source
# File lib/mini_histogram/plot.rb, line 39 def plot raise "@histogram cannot be empty set via `values=` or `histogram=` methods" if @histogram.nil? @histogram.plot(**@options) end
values=(values)
click to toggle source
# File lib/mini_histogram/plot.rb, line 45 def values=(values) @histogram = MiniHistogram.new(values) end