Class: Fdlint::Parser::HTML::Document

Inherits:
Tag show all
Defined in:
lib/fdlint/parser/html/struct.rb

Constant Summary

Constants included from Query

Query::CLASS, Query::ID, Query::PROP, Query::PROP_PAIR, Query::WORD

Instance Attribute Summary

Attributes inherited from Element

#children, #close_type, #ending, #parent, #position, #props, #scopes, #tag

Instance Method Summary collapse

Methods included from Query

#match?, #query

Methods included from Matchable

#=~

Methods inherited from Element

#[], #auto_close?, #closed?, #each, #has_prop?, #has_scope?, #in_scope?, #inline?, #inner_html, #inner_text, #prop, #prop_text, #prop_value, #self_closed?, #stylesheet_link?, #tag_name, #to_s, #top_level?

Constructor Details

#initialize(children = []) ⇒ Document

Returns a new instance of Document.



202
203
204
205
# File 'lib/fdlint/parser/html/struct.rb', line 202

def initialize( children=[] )
  super(nil, {}, children || [])
  @position = Position.new(0,0,0)
end

Instance Method Details

#==(other) ⇒ Object



207
208
209
210
211
212
213
214
215
# File 'lib/fdlint/parser/html/struct.rb', line 207

def ==(other)
  if other.is_a?(Array)
    return children == other
  elsif other.is_a?(Document)
    return children == other.children
  else
    super
  end
end

#empty?Boolean

Returns:

  • (Boolean)


217
218
219
# File 'lib/fdlint/parser/html/struct.rb', line 217

def empty?
  children.empty?
end

#has_dtd?Boolean Also known as: have_dtd?

Returns:

  • (Boolean)


221
222
223
# File 'lib/fdlint/parser/html/struct.rb', line 221

def has_dtd?
  !empty? && children.first.is_a?( DTDElement )
end

#outer_htmlObject



227
228
229
# File 'lib/fdlint/parser/html/struct.rb', line 227

def outer_html
  children.map(&:outer_html).to_a.join
end