Class: Scruffy::Formatters::Base
- Inherits:
-
Object
- Object
- Scruffy::Formatters::Base
- Defined in:
- lib/scruffy/formatters.rb
Overview
Scruffy::Formatters::Base
- Author
-
Brasten Sager
- Date
-
August 16th, 2006
Formatters are used to format the values displayed on the y-axis by setting graph.value_formatter.
Direct Known Subclasses
Instance Method Summary collapse
-
#route_format(target, idx, options = {}) ⇒ Object
Called by the value marker component.
Instance Method Details
#route_format(target, idx, options = {}) ⇒ Object
Called by the value marker component. Routes the format call to one of a couple possible methods.
If the formatter defines a #format method, the returned value is used as the value. If the formatter defines a #format! method, the value passed is expected to be modified, and is used as the value. (This may not actually work, in hindsight.)
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/scruffy/formatters.rb', line 31 def route_format(target, idx, = {}) args = [target, idx, ] if respond_to?(:format) send :format, *args[0...self.method(:format).arity] elsif respond_to?(:format!) send :format!, *args[0...self.method(:format!).arity] target else raise NameError, "Formatter subclass must container either a format() method or format!() method." end end |