class

HTML5::Token

Inherits Reference < Object

A Token consists of a TokenType and some data (tag name for start and end tags, content for text, comments and doctypes). A tag Token may also contain an array of Attributes. data is unescaped for all Tokens (it looks like "a<b" rather than "a<b"). For tag Tokens, data_atom is the atom for data, or zero if data is not a known tag name.

Constructors

new(type : HTML5::TokenType = TokenType::Error, data_atom : HTML5::Atom::Atom = Atom::Atom.zero, data : String = "", attr : Array(HTML5::Attribute) = Array(Attribute).new(0))
Source

Instance methods

attr
Source
attr=(attr : Array(Attribute))
Source
data
Source
data=(data : String)
Source
data_atom
Source
data_atom=(data_atom : Atom::Atom)
Source
tag_string

returns a string representation of a tag Token's data and attr

Source
to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source
to_s

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.

Source
type
Source
type=(type : TokenType)
Source