module MiniHistogram::MiniUnicodePlot::ValueTransformer
Constants
- PREDEFINED_TRANSFORM_FUNCTIONS
Public Instance Methods
transform_name(func, basename="")
click to toggle source
# File lib/mini_histogram/plot.rb, line 218 def transform_name(func, basename="") return basename unless func case func when String, Symbol name = func when ->(f) { f.respond_to?(:name) } name = func.name else name = "custom" end "#{basename} [#{name}]" end
transform_values(func, values)
click to toggle source
# File lib/mini_histogram/plot.rb, line 200 def transform_values(func, values) return values unless func unless func.respond_to?(:call) func = PREDEFINED_TRANSFORM_FUNCTIONS[func] unless func.respond_to?(:call) raise ArgumentError, "func must be callable" end end case values when Numeric func.(values) else values.map(&func) end end