Class: ConvertorTag

Inherits:
Object
  • Object
show all
Defined in:
lib/convertor-tags.rb

Instance Method Summary collapse

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

#tagsObject



7
8
9
# File 'lib/convertor-tags.rb', line 7

def tags
  @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