Sha256: aeb6b28218974292374be68d8366fd7dd051d4835fcf9ad83f6a44ecd5bf5d3d
Contents?: true
Size: 1023 Bytes
Versions: 3
Compression:
Stored size: 1023 Bytes
Contents
module Nokogiri module XML class Element def selector sel = name if !self['id'].nil? sel = sel + '#' + self['id'].split(' ').join('#') end if !self['class'].nil? sel = sel + '.' + self['class'].split(' ').join('.') end attributes.select{|k,v| k != 'class' && k != 'id'}.each { |name, value| sel = sel + "[#{name}='#{value}']" } sel end def selector_and_text [selector, text] end alias a selector_and_text def child_loop yield self end def child_a(index) element_children[index].selector_and_text end def selector_and_childs [selector] + children.select{|c| c.elem? || c.text.strip.size > 0}.map{|c| if !c.elem? c.text elsif c.element_children.size == 0 c.selector_and_text else c.selector_and_childs end } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
arti_mark-0.0.1.beta2 | spec/nokogiri_test_helper.rb |
arti_mark-0.0.1.beta1 | spec/nokogiri_test_helper.rb |
arti_mark-0.0.1.beta0 | spec/nokogiri_test_helper.rb |