class Loincloth::Block
Constants
- EMPHASIS
- H1_BLOCK
- H2_BLOCK
- HTML_LI_SEPARATOR
- IMAGE
- LINK
- LIST_BLOCK
- LI_SEPARATOR
- STRONG
Public Instance Methods
emphasize()
click to toggle source
# File lib/loincloth/block.rb, line 44 def emphasize gsub! EMPHASIS do |s| "<em>#{$1}</em>" end end
imaginize()
click to toggle source
# File lib/loincloth/block.rb, line 38 def imaginize gsub! IMAGE do |s| "<img src=\"#{$2}\" alt=\"#{$1}\" title=\"#{$1}\" />" end end
is_h1?()
click to toggle source
# File lib/loincloth/block.rb, line 56 def is_h1? h1_text end
is_h2?()
click to toggle source
# File lib/loincloth/block.rb, line 60 def is_h2? h2_text end
is_list?()
click to toggle source
# File lib/loincloth/block.rb, line 64 def is_list? list_text end
is_paragraph?()
click to toggle source
# File lib/loincloth/block.rb, line 68 def is_paragraph? !is_h1? && !is_h2? && !is_list? end
link()
click to toggle source
# File lib/loincloth/block.rb, line 32 def link gsub! LINK do |s| "<a href=\"#{$2}\" title=\"#{$1}\">#{$1}</a>" end end
process()
click to toggle source
# File lib/loincloth/block.rb, line 5 def process to_h1 to_h2 to_list to_paragraph strongize emphasize imaginize link end
strongize()
click to toggle source
# File lib/loincloth/block.rb, line 50 def strongize gsub! STRONG do |s| "<strong>#{$1}</strong>" end end
to_h1()
click to toggle source
# File lib/loincloth/block.rb, line 16 def to_h1 replace "<h1>#{h1_text}</h1>" if is_h1? end
to_h2()
click to toggle source
# File lib/loincloth/block.rb, line 20 def to_h2 replace "<h2>#{h2_text}</h2>" if is_h2? end
to_list()
click to toggle source
# File lib/loincloth/block.rb, line 24 def to_list replace "<ul>\n#{list_items_text}\n</ul>" if is_list? end
to_paragraph()
click to toggle source
# File lib/loincloth/block.rb, line 28 def to_paragraph replace "<p>#{self}</p>" if is_paragraph? end
Private Instance Methods
h1_text()
click to toggle source
# File lib/loincloth/block.rb, line 84 def h1_text @h1_text ||= self[H1_BLOCK, 1] end
h2_text()
click to toggle source
# File lib/loincloth/block.rb, line 88 def h2_text @h2_text ||= self[H2_BLOCK, 1] end
list_items()
click to toggle source
# File lib/loincloth/block.rb, line 100 def list_items list_text.split LI_SEPARATOR end
list_items_text()
click to toggle source
# File lib/loincloth/block.rb, line 96 def list_items_text " <li>#{list_items.join HTML_LI_SEPARATOR}</li>" end
list_text()
click to toggle source
# File lib/loincloth/block.rb, line 92 def list_text @list_text ||= self[LIST_BLOCK, 1] end