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
Returns a new instance of Converter.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/deplate/converter.rb', line 45 def initialize(formatter="html", args={}) Deplate::Converter.setup @master = args[:master] @options = args[:options] @options ||= @master..dup if @master @options ||= Deplate::Core. @options.fmt = formatter @options.modules ||= args[:modules] || [] Deplate::Core.require_standard(@options) if block_given? yield(self) end @deplate = Deplate::Core.new(formatter, :options => @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
72 73 74 75 76 77 78 |
# File 'lib/deplate/converter.rb', line 72 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.
35 36 37 |
# File 'lib/deplate/converter.rb', line 35 def setup_done @setup_done end |
Instance Attribute Details
#deplate ⇒ Object (readonly)
Returns the value of attribute deplate.
30 31 32 |
# File 'lib/deplate/converter.rb', line 30 def deplate @deplate end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
30 31 32 |
# File 'lib/deplate/converter.rb', line 30 def @options end |
Class Method Details
.setup ⇒ Object
37 38 39 40 41 42 |
# File 'lib/deplate/converter.rb', line 37 def setup unless @setup_done Deplate::Core.collect_standard @setup_done = true end end |
Instance Method Details
#convert_file(filename) ⇒ Object
68 69 70 |
# File 'lib/deplate/converter.rb', line 68 def convert_file(filename) @deplate.send(@formatter_method, nil, filename) end |
#convert_string(string) ⇒ Object
64 65 66 |
# File 'lib/deplate/converter.rb', line 64 def convert_string(string) @deplate.send(@formatter_method, string) end |