Class: Propolize::Paragraph

Inherits:
BaseText show all
Defined in:
lib/propolize.rb

Overview

A paragraph.

Constant Summary collapse

@@tagsMap =
{"bq" => {:tag => "blockquote"}}

Instance Attribute Summary

Attributes inherited from BaseText

#document

Instance Method Summary collapse

Methods inherited from BaseText

#critiqueClassHtml, #writeToDocument

Constructor Details

#initialize(text, options = {}) ⇒ Paragraph

Returns a new instance of Paragraph.



668
669
670
671
672
673
# File 'lib/propolize.rb', line 668

def initialize(text, options = {})
  @text = text
  @isCritique = options[:isCritique] || false
  @tag = options[:tag]
  initializeStartEndTags
end

Instance Method Details

#classesHtml(classNames) ⇒ Object



697
698
699
700
701
702
703
# File 'lib/propolize.rb', line 697

def classesHtml(classNames)
  if classNames.length == 0 then
    return ""
  else
    return " class=\"#{classNames.join(" ")}\""
  end
end

#initializeStartEndTagsObject



675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
# File 'lib/propolize.rb', line 675

def initializeStartEndTags
  @tagName = "p"
  className = nil
  if @tag then
    tagDescriptor = @@tagsMap[@tag]
    if tagDescriptor == nil then
      raise DocumentError, "Unknown tag: #{@tag.inspect}"
    end
    @tagName = tagDescriptor[:tag]
    @className = tagDescriptor[:class]
  end
  classNames = []
  if @isCritique then
    classNames.push("critique")
  end
  if @classname then
    classNames.push(@className)
  end
  @startTag = "<#{@tagName}#{classesHtml(classNames)}>"
  @endTag = "</#{@tagName}>"
end

#to_sObject



705
706
707
# File 'lib/propolize.rb', line 705

def to_s
  return "Paragraph: #{@text.inspect}"
end

#toHtmlObject



709
710
711
# File 'lib/propolize.rb', line 709

def toHtml
  return "#{@startTag}#{@document.processText(@text)}#{@endTag}"
end