class Genit::Builder

Build a document, that may be a fragment, from various sources.

Public Class Methods

new(document) click to toggle source

Public: Constructor.

document - A Nokogiri::XML::Document

# File lib/genit/builders/builder.rb, line 12
def initialize document
  @document = document
end

Public Instance Methods

replace(css_rule, replacement) click to toggle source

Public: Replace a tag (and its children) from the current document by a string.

css_rule - The String css rule to find the tag replacement - The replacement String

Examples

doc = builder.replace('genit.pages', "<working />")

Return the updated Nokogiri::XML::Document document.

# File lib/genit/builders/builder.rb, line 27
def replace css_rule, replacement
  tag = @document.at_css(css_rule)
  tag.replace replacement
  @document
end