Class: MiniHTML::AST::Tag

Inherits:
Base
  • Object
show all
Defined in:
lib/minihtml/ast/tag.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#original_token, #position_end, #position_start

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Tag

Returns a new instance of Tag.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/minihtml/ast/tag.rb', line 10

def initialize(token)
  super
  lit = token[:literal]
  if lit.start_with? "</"
    @bad_tag = true
    @name = token[:literal][2...]
  else
    @name = token[:literal][1...]
  end

  @self_closing = false
  @attributes = []
  @children = []
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



6
7
8
# File 'lib/minihtml/ast/tag.rb', line 6

def attributes
  @attributes
end

#bad_tagObject Also known as: bad_tag?

Returns the value of attribute bad_tag.



6
7
8
# File 'lib/minihtml/ast/tag.rb', line 6

def bad_tag
  @bad_tag
end

#childrenObject

Returns the value of attribute children.



6
7
8
# File 'lib/minihtml/ast/tag.rb', line 6

def children
  @children
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/minihtml/ast/tag.rb', line 6

def name
  @name
end

#self_closingObject Also known as: self_closing?

Returns the value of attribute self_closing.



6
7
8
# File 'lib/minihtml/ast/tag.rb', line 6

def self_closing
  @self_closing
end