Class: Scruffy::Formatters::Custom

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

Methods inherited from Base

#route_format

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

#procObject (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, options)
  proc.call(target, idx, options)
end