class Evertils::Helper::Xml
Attributes
doc[RW]
Public Class Methods
new(doc)
click to toggle source
@since 0.3.15
# File lib/evertils/helpers/xml.rb, line 8 def initialize(doc) raise ArgumentError, "doc param required" unless doc @doc = doc.first end
Public Instance Methods
a(link, content)
click to toggle source
@since 0.3.15
# File lib/evertils/helpers/xml.rb, line 16 def a(link, content) conf = { href: link, content: content } create(:a, conf) end
br()
click to toggle source
@since 0.3.15
# File lib/evertils/helpers/xml.rb, line 37 def br create(:br) end
create(element, conf = {})
click to toggle source
@since 0.3.15
# File lib/evertils/helpers/xml.rb, line 67 def create(element, conf = {}) el = Nokogiri::XML::Node.new(element.to_s, @doc) return el if conf.empty? conf.each_pair do |k, v| if el.respond_to? "#{k}=" el.send("#{k}=", v) elsif el.respond_to? k el.send(k, v) else el[k] = v end end el end
div(*children)
click to toggle source
@since 0.3.15
# File lib/evertils/helpers/xml.rb, line 51 def div(*children) el = create(:div) children.each { |child| el.add_child(child) } el end
li(*children)
click to toggle source
@since 0.3.15
# File lib/evertils/helpers/xml.rb, line 43 def li(*children) el = create(:li) children.each { |child| el.add_child(child) } el end
span(content)
click to toggle source
@since 0.3.18
# File lib/evertils/helpers/xml.rb, line 27 def span(content) conf = { content: content } create(:span, conf) end
ul(*children)
click to toggle source
@since 0.3.18
# File lib/evertils/helpers/xml.rb, line 59 def ul(*children) el = create(:ul) children.each { |child| el.add_child(child) } el end