Class: TagAlong
- Inherits:
-
Object
- Object
- TagAlong
- Defined in:
- lib/tag_along.rb,
lib/tag_along/offsets.rb,
lib/tag_along/version.rb
Defined Under Namespace
Classes: Offsets
Constant Summary collapse
- VERSION =
'0.6.1'
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
#initialize(text, offsets) ⇒ TagAlong
Returns a new instance of TagAlong.
13 14 15 16 17 18 19 |
# File 'lib/tag_along.rb', line 13 def initialize(text, offsets) @offsets = offsets.is_a?(Offsets) ? offsets : Offsets.new(offsets) @text = text @split_text = nil @tagged_text = nil split_text end |
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 |
# File 'lib/tag_along.rb', line 21 def tag(open_tag, close_tag) @tagged_text = @split_text.inject([]) do |res, t| if t[:tagged] [open_tag, t[:text], close_tag].each { |text| res << text } else res << t[:text] end res end.join('') end |