Class: TextMarker::Marker
- Inherits:
-
Object
- Object
- TextMarker::Marker
- Defined in:
- lib/textmarker.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text = "") ⇒ Marker
constructor
A new instance of Marker.
- #mark_all_ocurrence_of(snippet_to_be_marked, tag = Tag.new) ⇒ Object
- #mark_first_ocurrence_of(snippet_to_be_marked, tag = Tag.new) ⇒ Object
Constructor Details
#initialize(text = "") ⇒ Marker
Returns a new instance of Marker.
8 9 10 |
# File 'lib/textmarker.rb', line 8 def initialize(text="") @text = text end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
6 7 8 |
# File 'lib/textmarker.rb', line 6 def text @text end |
Instance Method Details
#mark_all_ocurrence_of(snippet_to_be_marked, tag = Tag.new) ⇒ Object
12 13 14 |
# File 'lib/textmarker.rb', line 12 def mark_all_ocurrence_of(snippet_to_be_marked, tag=Tag.new) @text.gsub(snippet_to_be_marked, build_marked_snippet(snippet_to_be_marked, tag)) end |
#mark_first_ocurrence_of(snippet_to_be_marked, tag = Tag.new) ⇒ Object
16 17 18 |
# File 'lib/textmarker.rb', line 16 def mark_first_ocurrence_of(snippet_to_be_marked, tag=Tag.new) @text.sub(snippet_to_be_marked, build_marked_snippet(snippet_to_be_marked, tag)) end |