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.



6
7
8
# File 'lib/better_html/tree/attributes_list.rb', line 6

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

Class Method Details

.from_nodes(nodes) ⇒ Object



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

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

Instance Method Details

#[](name) ⇒ Object



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

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

#each(&block) ⇒ Object



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

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