Class: Rbml::Doc
Instance Attribute Summary collapse
-
#assemble_doc ⇒ Object
Returns the value of attribute assemble_doc.
-
#formatted_doc ⇒ Object
Returns the value of attribute formatted_doc.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
#initialize, #instance_eval_each
Constructor Details
This class inherits a constructor from Rbml::Base
Instance Attribute Details
#assemble_doc ⇒ Object
Returns the value of attribute assemble_doc.
5 6 7 |
# File 'lib/doc.rb', line 5 def assemble_doc @assemble_doc end |
#formatted_doc ⇒ Object
Returns the value of attribute formatted_doc.
6 7 8 |
# File 'lib/doc.rb', line 6 def formatted_doc @formatted_doc end |
Class Method Details
.render(language, options, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/doc.rb', line 8 def self.render(language, , &block) d = Doc.new(language) d.assemble_doc = "" display = lambda do |result| if result.kind_of? Array result.each {|r| r.kind_of?(Proc) ? d.instance_eval_each(r, &display) : d.assemble_doc<<(r) } else d.assemble_doc << result end end d.assemble_doc << d.dsl.start_tag() d.instance_eval_each(block, &display) d.assemble_doc << d.dsl.end_tag d.formatted_doc = '' begin d.format ensure d.print end end |
Instance Method Details
#format ⇒ Object
29 30 31 |
# File 'lib/doc.rb', line 29 def format dsl.format(self) end |
#print ⇒ Object
33 34 35 |
# File 'lib/doc.rb', line 33 def print formatted_doc.blank? ? assemble_doc : formatted_doc end |