Class: HtmlParagraph
- Inherits:
-
Object
- Object
- HtmlParagraph
- Defined in:
- lib/text-to-html/html_paragraph.rb
Overview
function: pulls text w/line breaks from clipboard, adds <p></p> to line breaks, and puts back on clipboard TODO: Enable classes
Instance Method Summary collapse
- #em ⇒ Object
-
#initialize(input, h_class) ⇒ HtmlParagraph
constructor
A new instance of HtmlParagraph.
- #strong ⇒ Object
- #to_paragraph ⇒ Object
- #use_class ⇒ Object
- #verbose ⇒ Object
Constructor Details
#initialize(input, h_class) ⇒ HtmlParagraph
Returns a new instance of HtmlParagraph.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/text-to-html/html_paragraph.rb', line 6 def initialize(input, h_class) # String to be parsed @input = input @hclass = h_class # Options @verbose = false @em = false @strong = false @use_class = false end |
Instance Method Details
#em ⇒ Object
34 35 36 |
# File 'lib/text-to-html/html_paragraph.rb', line 34 def em @em = true end |
#strong ⇒ Object
38 39 40 |
# File 'lib/text-to-html/html_paragraph.rb', line 38 def strong @strong = true end |
#to_paragraph ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/text-to-html/html_paragraph.rb', line 18 def to_paragraph raw_in = @input.gsub("\t", '').gsub("\r", '').gsub("\"", '').split("\n") puts raw_in.inspect if @verbose p_string = "" raw_in.each do | line | if line.length > 0 p_string << "<p>\n\t#{"<em>" if @em}#{"<strong>" if @strong}#{line}#{"</strong>" if @strong}#{"</em>" if @em}\n</p>\n" end end p_string.chomp! puts p_string if @verbose return p_string end |
#use_class ⇒ Object
46 47 48 |
# File 'lib/text-to-html/html_paragraph.rb', line 46 def use_class @use_class = true end |
#verbose ⇒ Object
42 43 44 |
# File 'lib/text-to-html/html_paragraph.rb', line 42 def verbose @verbose = true end |