Class: Html::Merge::FileAnalysis

Inherits:
Object
  • Object
show all
Defined in:
lib/html/merge/file_analysis.rb,
sig/html/merge.rbs

Overview

One native parser pass proving HTML structure, explicit IDs, and safe source ranges.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ FileAnalysis

Returns a new instance of FileAnalysis.

Parameters:

  • source (String)


9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/html/merge/file_analysis.rb', line 9

def initialize(source)
  @source = source.to_s
  @backend = BACKEND_REFERENCE.id.to_sym
  @errors = []
  parse!
rescue StandardError => e
  @root_node = nil
  @wrappers = [].freeze
  @document_semantics = nil
  @issues = [].freeze
  @errors = [e].freeze
end

Instance Attribute Details

#backendSymbol (readonly)

Returns the value of attribute backend.

Returns:

  • (Symbol)


7
8
9
# File 'lib/html/merge/file_analysis.rb', line 7

def backend
  @backend
end

#document_semanticsObject (readonly)

Returns the value of attribute document_semantics.

Returns:

  • (Object)


7
8
9
# File 'lib/html/merge/file_analysis.rb', line 7

def document_semantics
  @document_semantics
end

#errorsArray[untyped] (readonly)

Returns the value of attribute errors.

Returns:

  • (Array[untyped])


7
8
9
# File 'lib/html/merge/file_analysis.rb', line 7

def errors
  @errors
end

#issuesArray[Hash[Symbol, untyped]] (readonly)

Returns the value of attribute issues.

Returns:

  • (Array[Hash[Symbol, untyped]])


7
8
9
# File 'lib/html/merge/file_analysis.rb', line 7

def issues
  @issues
end

#root_nodeObject (readonly)

Returns the value of attribute root_node.

Returns:

  • (Object)


7
8
9
# File 'lib/html/merge/file_analysis.rb', line 7

def root_node
  @root_node
end

#sourceString (readonly)

Returns the value of attribute source.

Returns:

  • (String)


7
8
9
# File 'lib/html/merge/file_analysis.rb', line 7

def source
  @source
end

#wrappersArray[NodeWrapper] (readonly)

Returns the value of attribute wrappers.

Returns:



7
8
9
# File 'lib/html/merge/file_analysis.rb', line 7

def wrappers
  @wrappers
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


22
# File 'lib/html/merge/file_analysis.rb', line 22

def valid? = errors.empty?