Class: BetterHtml::Tree::AttributesList

Inherits:
Object
  • Object
show all
Defined in:
lib/better_html/tree/attributes_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list) ⇒ AttributesList

Returns a new instance of AttributesList.



14
15
16
# File 'lib/better_html/tree/attributes_list.rb', line 14

def initialize(list)
  @list = list || []
end

Class Method Details

.from_nodes(nodes) ⇒ Object



9
10
11
# File 'lib/better_html/tree/attributes_list.rb', line 9

def from_nodes(nodes)
  new(nodes&.map { |node| Tree::Attribute.from_node(node) })
end

Instance Method Details

#[](name) ⇒ Object



18
19
20
21
22
# File 'lib/better_html/tree/attributes_list.rb', line 18

def [](name)
  @list.find do |attribute|
    attribute.name == name.downcase
  end
end

#each(&block) ⇒ Object



24
25
26
# File 'lib/better_html/tree/attributes_list.rb', line 24

def each(&block)
  @list.each(&block)
end