Class: TagAlong
- Inherits:
-
Object
- Object
- TagAlong
- Defined in:
- lib/tag_along.rb,
lib/tag_along/offsets.rb,
lib/tag_along/version.rb,
lib/tag_along/tagged_text.rb
Defined Under Namespace
Classes: Offsets, TaggedText
Constant Summary collapse
- VERSION =
'0.8.3'
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text, offsets) ⇒ TagAlong
constructor
A new instance of TagAlong.
- #tag(open_tag, close_tag) ⇒ Object
Constructor Details
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/tag_along.rb', line 7 def text @text end |
Class Method Details
.version ⇒ Object
9 10 11 |
# File 'lib/tag_along.rb', line 9 def self.version VERSION end |
Instance Method Details
#tag(open_tag, close_tag) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tag_along.rb', line 21 def tag(open_tag, close_tag) opts = { open_tag: open_tag, close_tag: close_tag, open_tag_subs: open_tag.scan(/%s/).size, close_tag_subs: close_tag.scan(/%s/).size, } @tagged_text = @split_text.inject([]) do |res, t| process_tag(res, t, opts) res end.join('') end |