Class: Decode::Comment::Tag

Inherits:
Node
  • Object
show all
Defined in:
lib/decode/comment/tag.rb

Direct Known Subclasses

Attribute, Parameter, Pragma, Yields

Instance Attribute Summary collapse

Attributes inherited from Node

#children

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#add, #children?, #each, #filter, #text, #traverse

Constructor Details

#initialize(directive) ⇒ Tag

Returns a new instance of Tag.



30
31
32
# File 'lib/decode/comment/tag.rb', line 30

def initialize(directive)
  @directive = directive
end

Instance Attribute Details

#directiveObject (readonly)

The directive that generated the tag.



36
37
38
# File 'lib/decode/comment/tag.rb', line 36

def directive
  @directive
end

Class Method Details

.match(text) ⇒ Object



11
12
13
# File 'lib/decode/comment/tag.rb', line 11

def self.match(text)
  self::PATTERN.match(text)
end

.parse(directive, text, lines, tags, level = 0) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/decode/comment/tag.rb', line 15

def self.parse(directive, text, lines, tags, level = 0)
  if match = self.match(text)
    node = self.build(directive, match)
    
    tags.parse(lines, level + 1) do |child|
      node.add(child)
    end
    
    return node
  else
    # Consume all nested nodes:
    tags.ignore(lines, level + 1)
  end
end