Class: TextMarker::Marker

Inherits:
Object
  • Object
show all
Defined in:
lib/textmarker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#textObject

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