Class: Deplate::Converter
- Inherits:
-
Object
- Object
- Deplate::Converter
- Defined in:
- lib/deplate/converter.rb
Class Attribute Summary collapse
-
.setup_done ⇒ Object
readonly
Returns the value of attribute setup_done.
Instance Attribute Summary collapse
-
#deplate ⇒ Object
readonly
Returns the value of attribute deplate.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #convert_file(filename) ⇒ Object
- #convert_string(string) ⇒ Object
-
#initialize(formatter = "html", args = {}) ⇒ Converter
constructor
A new instance of Converter.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(formatter = "html", args = {}) ⇒ Converter
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/deplate/converter.rb', line 44 def initialize(formatter="html", args={}) Deplate::Converter.setup @master = args[:master] = args[:options] ||= @master..dup if @master ||= Deplate::Core. .fmt = formatter .modules ||= args[:modules] || [] Deplate::Core.require_standard() if block_given? yield(self) end @deplate = Deplate::Core.new(formatter, :options => ) vars = args[:variables] vars ||= @master.variables.dup if @master @deplate.instance_eval {@variables = vars} if vars @formatter_method = "to_%s" % formatter.gsub(/[^[:alnum:]_]/, "_") end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/deplate/converter.rb', line 71 def method_missing(method, *args, &block) if @deplate.respond_to?(method) @deplate.send(method, *args, &block) else super end end |
Class Attribute Details
.setup_done ⇒ Object (readonly)
Returns the value of attribute setup_done.
34 35 36 |
# File 'lib/deplate/converter.rb', line 34 def setup_done @setup_done end |
Instance Attribute Details
#deplate ⇒ Object (readonly)
Returns the value of attribute deplate.
29 30 31 |
# File 'lib/deplate/converter.rb', line 29 def deplate @deplate end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
29 30 31 |
# File 'lib/deplate/converter.rb', line 29 def end |
Class Method Details
.setup ⇒ Object
36 37 38 39 40 41 |
# File 'lib/deplate/converter.rb', line 36 def setup unless @setup_done Deplate::Core.collect_standard @setup_done = true end end |
Instance Method Details
#convert_file(filename) ⇒ Object
67 68 69 |
# File 'lib/deplate/converter.rb', line 67 def convert_file(filename) @deplate.send(@formatter_method, nil, filename) end |
#convert_string(string) ⇒ Object
63 64 65 |
# File 'lib/deplate/converter.rb', line 63 def convert_string(string) @deplate.send(@formatter_method, string) end |