Class: Dryml::DrymlDoc::Taglib
- Inherits:
-
Object
- Object
- Dryml::DrymlDoc::Taglib
- Includes:
- classy_module do def comment_intro comment && comment =~ /(.*?)^#/m ? $1 : comment end def comment_rest comment && comment[comment_intro.length.classy_module do def comment_intro comment && comment =~ /(.*?)^#/m ? $1 : comment end def comment_rest comment && comment[comment_intro.length..-1] end %w(comment comment_intro comment_rest).each do |m| class_eval "def #{m}_html; Maruku.new(#{m}).to_html.gsub(/&/, '&'); end" end end
- Defined in:
- lib/dryml/dryml_doc.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#tag_defs ⇒ Object
readonly
Returns the value of attribute tag_defs.
Instance Method Summary collapse
- #comment ⇒ Object
-
#initialize(home, filename, name = nil) ⇒ Taglib
constructor
A new instance of Taglib.
- #parse_file(filename) ⇒ Object
Constructor Details
#initialize(home, filename, name = nil) ⇒ Taglib
Returns a new instance of Taglib.
33 34 35 36 37 |
# File 'lib/dryml/dryml_doc.rb', line 33 def initialize(home, filename, name=nil) @name = name || filename.sub(/.dryml$/, '')[home.length+1..-1] @filename = filename parse_file(filename) end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
45 46 47 |
# File 'lib/dryml/dryml_doc.rb', line 45 def doc @doc end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
45 46 47 |
# File 'lib/dryml/dryml_doc.rb', line 45 def filename @filename end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
45 46 47 |
# File 'lib/dryml/dryml_doc.rb', line 45 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
45 46 47 |
# File 'lib/dryml/dryml_doc.rb', line 45 def source @source end |
#tag_defs ⇒ Object (readonly)
Returns the value of attribute tag_defs.
45 46 47 |
# File 'lib/dryml/dryml_doc.rb', line 45 def tag_defs @tag_defs end |
Instance Method Details
#comment ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/dryml/dryml_doc.rb', line 47 def comment first_node = doc[0][0] if first_node.is_a?(REXML::Comment) doc.restore_erb_scriptlets(first_node.to_s.strip) elsif first_node.to_s.strip.starts_with?("[![DRYML-ERB") text = doc.restore_erb_scriptlets(first_node.to_s.strip) text.match(/<%#(.*?)%>/m)[1] rescue nil end end |