Class: Scruffy::Formatters::Custom
- Defined in:
- lib/scruffy/formatters.rb
Overview
Allows you to pass in a Proc for use as a formatter.
Use:
graph.value_formatter = Scruffy::Formatters::Custom.new { |value, idx, options| “Displays Returned Value” }
Instance Attribute Summary collapse
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Instance Method Summary collapse
- #format(target, idx, options) ⇒ Object
-
#initialize(&block) ⇒ Custom
constructor
A new instance of Custom.
Methods inherited from Base
Constructor Details
#initialize(&block) ⇒ Custom
Returns a new instance of Custom.
57 58 59 |
# File 'lib/scruffy/formatters.rb', line 57 def initialize(&block) @proc = block end |
Instance Attribute Details
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
55 56 57 |
# File 'lib/scruffy/formatters.rb', line 55 def proc @proc end |
Instance Method Details
#format(target, idx, options) ⇒ Object
61 62 63 |
# File 'lib/scruffy/formatters.rb', line 61 def format(target, idx, ) proc.call(target, idx, ) end |