Class: Pekky::Format::Wrapper
- Inherits:
-
Object
- Object
- Pekky::Format::Wrapper
- Defined in:
- lib/pekky/format.rb
Overview
The wrapper class acts as a container for a set of renderers or filters. It’s most essential job is to allow syntax like this:
Format::Formatters.textile("h1. blah")
This class should never be instanced, or accessed directly. Instead, we use the Renderers and Filters subclasses.
Direct Known Subclasses
Class Attribute Summary collapse
-
.call_with ⇒ Object
Returns the value of attribute call_with.
-
.klasses ⇒ Object
Returns the value of attribute klasses.
Class Method Summary collapse
-
.[](name) ⇒ Object
Shortcut for accessing a transformer class by name.
-
.add(name, klass) ⇒ Object
Adds a transformer to the existing collection.
-
.each ⇒ Object
An iterator for looping over the transformer.
-
.keys ⇒ Object
Returns all the names of the transformers.
-
.method_missing(name, *args) ⇒ Object
Method missing is used here to provide nice syntax for accessing transformer as methods.
-
.values ⇒ Object
Returns the actual transformers themselves.
Class Attribute Details
.call_with ⇒ Object
Returns the value of attribute call_with.
27 28 29 |
# File 'lib/pekky/format.rb', line 27 def call_with @call_with end |
.klasses ⇒ Object
Returns the value of attribute klasses.
27 28 29 |
# File 'lib/pekky/format.rb', line 27 def klasses @klasses end |
Class Method Details
.[](name) ⇒ Object
Shortcut for accessing a transformer class by name.
36 37 38 |
# File 'lib/pekky/format.rb', line 36 def self.[](name) self.klasses[name] end |
.add(name, klass) ⇒ Object
Adds a transformer to the existing collection.
31 32 33 |
# File 'lib/pekky/format.rb', line 31 def self.add(name, klass) (self.klasses ||= {})[name] = klass end |
.each ⇒ Object
An iterator for looping over the transformer. The block will recieve the name and the actual class.
52 53 54 |
# File 'lib/pekky/format.rb', line 52 def self.each self.klasses.each { |k, v| yield k, v } end |
.keys ⇒ Object
Returns all the names of the transformers.
41 42 43 |
# File 'lib/pekky/format.rb', line 41 def self.keys self.klasses.keys end |
.method_missing(name, *args) ⇒ Object
Method missing is used here to provide nice syntax for accessing transformer as methods.
58 59 60 61 62 63 64 |
# File 'lib/pekky/format.rb', line 58 def self.method_missing(name, *args) if self.klasses[name] self.klasses[name].send(self.call_with, *args) else super end end |
.values ⇒ Object
Returns the actual transformers themselves.
46 47 48 |
# File 'lib/pekky/format.rb', line 46 def self.values self.klasses.values end |