Class: ConvertorTag
- Inherits:
-
Object
- Object
- ConvertorTag
- Defined in:
- lib/convertor-tags.rb
Instance Method Summary collapse
-
#initialize(text) ⇒ ConvertorTag
constructor
A new instance of ConvertorTag.
- #tags ⇒ Object
- #text_inside_tag(tag) ⇒ Object
- #text_with_tag(tag) ⇒ Object
Constructor Details
#initialize(text) ⇒ ConvertorTag
Returns a new instance of ConvertorTag.
3 4 5 |
# File 'lib/convertor-tags.rb', line 3 def initialize(text) @text = text end |
Instance Method Details
#tags ⇒ Object
7 8 9 |
# File 'lib/convertor-tags.rb', line 7 def @text.scan(/{@\s*(.*)\s*@}.*{@ \/\1 @}/m).flatten end |
#text_inside_tag(tag) ⇒ Object
11 12 13 |
# File 'lib/convertor-tags.rb', line 11 def text_inside_tag(tag) @text.match(/{@\s*#{tag}\s*@}(.*){@ \/#{tag} @}/m)[1] rescue nil end |
#text_with_tag(tag) ⇒ Object
15 16 17 |
# File 'lib/convertor-tags.rb', line 15 def text_with_tag(tag) @text.match(/{@\s*#{tag}\s*@}(.*){@ \/#{tag} @}/m)[0] rescue nil end |