Module: Hpricot::Elem::Trav

Includes:
Container::Trav
Included in:
Hpricot::Elem
Defined in:
lib/ext/hpricot/modules.rb,
lib/ext/hpricot/traverse.rb,
lib/ext/hpricot/traverse.rb,
lib/ext/hpricot/traverse.rb

Instance Method Summary collapse

Methods included from Container::Trav

#classes, #containers, #each_child, #each_child_with_index, #each_hyperlink, #each_hyperlink_uri, #each_uri, #filter, #find_element, #following_siblings, #get_element_by_id, #get_elements_by_tag_name, #insert_after, #insert_before, #next_sibling, #preceding_siblings, #previous_sibling, #replace_child, #siblings_at, #traverse_text_internal

Methods included from Traverse

#after, #at, #before, #bogusetag?, #children_of_type, #clean_path, #comment?, #css_path, #doc?, #doctype?, #elem?, filter, #following, #get_subnode, #html, #index, #inner_html=, #inner_text, #make, #next, #node_position, #nodes_at, #position, #preceding, #previous, #procins?, #search, #swap, #text?, #to_html, #to_original_html, #to_plain_text, #traverse_element, #traverse_text, #xmldecl?, #xpath

Instance Method Details

#get_attribute(name) ⇒ Object Also known as: []



817
818
819
820
821
# File 'lib/ext/hpricot/traverse.rb', line 817

def get_attribute(name)
  a = self.raw_attributes && self.raw_attributes[name.to_s]
  a = Hpricot.uxs(a) if a
  a
end

#has_attribute?(name) ⇒ Boolean

Returns:

  • (Boolean)


814
815
816
# File 'lib/ext/hpricot/traverse.rb', line 814

def has_attribute?(name)
  self.raw_attributes && self.raw_attributes.has_key?(name.to_s)
end

#remove_attribute(name) ⇒ Object



829
830
831
832
833
834
835
# File 'lib/ext/hpricot/traverse.rb', line 829

def remove_attribute(name)
  name = name.to_s
  if has_attribute? name
    altered!
    self.raw_attributes.delete(name)
  end
end

#set_attribute(name, val) ⇒ Object Also known as: []=



823
824
825
826
827
# File 'lib/ext/hpricot/traverse.rb', line 823

def set_attribute(name, val)
  altered!
  self.raw_attributes ||= {}
  self.raw_attributes[name.to_s] = val.fast_xs
end

#traverse_all_element {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



646
647
648
649
# File 'lib/ext/hpricot/traverse.rb', line 646

def traverse_all_element(&block)
  yield self
  children.each {|c| c.traverse_all_element(&block) } if children
end

#traverse_some_element(name_set) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



665
666
667
668
# File 'lib/ext/hpricot/traverse.rb', line 665

def traverse_some_element(name_set, &block)
  yield self if name_set.include? self.name
  children.each {|c| c.traverse_some_element(name_set, &block) } if children
end