class UnbalancedTagError
The name of a closing tag fails to match up with the corresponding opening tag.
Definitions
def initialize(buffer, opening_tag, closing_tag = nil)
Initialize an error for mismatched source tags.
Signature
-
parameter
bufferString The markup source buffer.
-
parameter
opening_tagObject The opening tag token.
-
parameter
closing_tagObject The closing tag token.
Implementation
def initialize(buffer, opening_tag, closing_tag = nil)
@buffer = buffer
@opening_tag = opening_tag
@closing_tag = closing_tag
end
def start_location
Locate the opening tag in the source buffer.
Signature
-
returns
XRB::Location The opening tag location.
Implementation
def start_location
XRB::Location.new(@buffer.read, opening_tag.offset)
end
def end_location
Locate the closing tag in the source buffer.
Signature
-
returns
XRB::Location | Nil The closing tag location.
Implementation
def end_location
if closing_tag and closing_tag.respond_to? :offset
XRB::Location.new(@buffer.read, closing_tag.offset)
end
end
def to_s
Convert this object to a string.
Signature
-
returns
String The resulting string.
Implementation
def to_s
if @closing_tag
"#{start_location}: #{@opening_tag} was not closed!"
else
"#{start_location}: #{@opening_tag} was closed by #{@closing_tag}!"
end
end