Class: Continuum::ClusteringData

Inherits:
Object
  • Object
show all
Defined in:
src/lib/continuum/clustering_data.rb

Overview

Encapsulates all of the data related to clustering within a page for a single test result

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unique_id, tag_name, attributes, text, children) ⇒ ClusteringData

Returns a new instance of ClusteringData.

Parameters:

  • unique_id (String)

    The id that uniquely identifies this clustering data.

  • tag_name (String)

    The name of the element associated with this clustering data.

  • attributes (Hash)

    The attribute names and value for the element associated with this clustering data.

  • text (String)

    The inner text for the element associated with this clustering data.

  • children (Array<ClusteringData>)

    The array of child clustering data.



41
42
43
44
45
46
47
# File 'src/lib/continuum/clustering_data.rb', line 41

def initialize(unique_id, tag_name, attributes, text, children)
    @unique_id = unique_id
    @tag_name = tag_name
    @attributes = attributes
    @text = text
    @children = children
end

Instance Attribute Details

#attributesHash

Gets the attribute names and value for the element associated with this clustering data.

Returns:

  • (Hash)

    The attribute names and value for the element associated with this clustering data.



24
25
26
# File 'src/lib/continuum/clustering_data.rb', line 24

def attributes
  @attributes
end

#childrenArray<ClusteringData>

Gets the array of child clustering data.

Returns:



34
35
36
# File 'src/lib/continuum/clustering_data.rb', line 34

def children
  @children
end

#tag_nameString

Gets the name of the element associated with this clustering data.

Returns:

  • (String)

    The name of the element associated with this clustering data.



19
20
21
# File 'src/lib/continuum/clustering_data.rb', line 19

def tag_name
  @tag_name
end

#textString

Gets the inner text for the element associated with this clustering data.

Returns:

  • (String)

    The inner text for the element associated with this clustering data.



29
30
31
# File 'src/lib/continuum/clustering_data.rb', line 29

def text
  @text
end

#unique_idString

Gets the id that uniquely identifies this clustering data.

Returns:

  • (String)

    The id that uniquely identifies this clustering data.



14
15
16
# File 'src/lib/continuum/clustering_data.rb', line 14

def unique_id
  @unique_id
end

Class Method Details

.from_json(json_data) ⇒ AccessibilityConcern

Parameters:

  • json_data (String, Hash)

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'src/lib/continuum/clustering_data.rb', line 51

def self.from_json(json_data)
    parsed = DataUtil.parse_json(json_data) || {}
  
    children = parsed['children'].map do |child_data|
        ClusteringData.from_json(child_data)
    end
    return new(
        parsed['uniqueId'],
        parsed['tagName'],
        parsed['attributes'],
        parsed['text'],
        children
    )
end