Class: AbstractPresentation
- Inherits:
-
Object
- Object
- AbstractPresentation
- Defined in:
- lib/abstract_presentation.rb
Overview
Present abstract, highlighting keywords
Instance Attribute Summary collapse
-
#class_keyword ⇒ Object
Returns the value of attribute class_keyword.
-
#keywords ⇒ Object
Returns the value of attribute keywords.
-
#tag_keyword ⇒ Object
Returns the value of attribute tag_keyword.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #begin_tag ⇒ Object
- #end_tag ⇒ Object
- #html_with_keywords ⇒ Object
-
#initialize(text = nil) ⇒ AbstractPresentation
constructor
A new instance of AbstractPresentation.
Constructor Details
#initialize(text = nil) ⇒ AbstractPresentation
Returns a new instance of AbstractPresentation.
36 37 38 39 40 41 |
# File 'lib/abstract_presentation.rb', line 36 def initialize(text=nil) @text=text @keywords=nil @tag_keyword="strong" @class_keyword=nil end |
Instance Attribute Details
#class_keyword ⇒ Object
Returns the value of attribute class_keyword.
34 35 36 |
# File 'lib/abstract_presentation.rb', line 34 def class_keyword @class_keyword end |
#keywords ⇒ Object
Returns the value of attribute keywords.
32 33 34 |
# File 'lib/abstract_presentation.rb', line 32 def keywords @keywords end |
#tag_keyword ⇒ Object
Returns the value of attribute tag_keyword.
33 34 35 |
# File 'lib/abstract_presentation.rb', line 33 def tag_keyword @tag_keyword end |
#text ⇒ Object
Returns the value of attribute text.
31 32 33 |
# File 'lib/abstract_presentation.rb', line 31 def text @text end |
Instance Method Details
#begin_tag ⇒ Object
43 44 45 46 |
# File 'lib/abstract_presentation.rb', line 43 def begin_tag class_out= @class_keyword ? " class='#{@class_keyword}'" : "" "<#{@tag_keyword}#{class_out}>" end |
#end_tag ⇒ Object
48 49 50 |
# File 'lib/abstract_presentation.rb', line 48 def end_tag "</#{@tag_keyword}>" end |
#html_with_keywords ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/abstract_presentation.rb', line 52 def html_with_keywords return "" if text.nil? out=CGI.escapeHTML(text).to_s.gsub("\n", "<br/>") if @keywords regexps=Regexp.new '('+@keywords.join("|")+')' out=out.gsub(regexps, "#{begin_tag}\\1#{end_tag}") end out end |