module Jekyll::Favicon::Utils::Tag
Favicon
rexml for include
Public Class Methods
build_xml(name, parent = nil, config = {})
click to toggle source
# File lib/jekyll/favicon/utils/tag.rb, line 31 def self.build_xml(name, parent = nil, config = {}) element = REXML::Element.new name, parent return Tag.populate_element element, config if config.is_a? Enumerable element.text = config and return element end
included(klass)
click to toggle source
# File lib/jekyll/favicon/utils/tag.rb, line 10 def self.included(klass) klass.extend(ClassMethods) end
mutate_find_or_create_element(parent, key)
click to toggle source
# File lib/jekyll/favicon/utils/tag.rb, line 14 def self.mutate_find_or_create_element(parent, key) parent.get_elements(key).first || parent.add_element(key) end
mutate_iterator(key, value, memo)
click to toggle source
# File lib/jekyll/favicon/utils/tag.rb, line 24 def self.mutate_iterator(key, value, memo) if key.start_with? "__" then memo.text = value elsif key.start_with? "_" then memo.add_attribute key[1..], value else Tag.mutate_xml Tag.mutate_find_or_create_element(memo, key), value end end
mutate_xml(parent, changes = {})
click to toggle source
# File lib/jekyll/favicon/utils/tag.rb, line 18 def self.mutate_xml(parent, changes = {}) changes.each_with_object(parent) do |(key, value), memo| mutate_iterator key, value, memo end end
populate_element(element, config)
click to toggle source
# File lib/jekyll/favicon/utils/tag.rb, line 38 def self.populate_element(element, config) config.each_with_object(element) do |(key, value), memo| populate_iterator key, value, memo end end
populate_iterator(key, value, memo)
click to toggle source
# File lib/jekyll/favicon/utils/tag.rb, line 44 def self.populate_iterator(key, value, memo) if key.start_with? "__" then memo.text = value elsif (child_key = key.match(/^_(.*)$/)) memo.add_attribute child_key[1], value else build_xml key, memo, value end end