Class: Genit::Builder
- Inherits:
-
Object
- Object
- Genit::Builder
- Defined in:
- lib/genit/builders/builder.rb
Overview
Build a document, that may be a fragment, from various sources.
Instance Method Summary collapse
-
#initialize(document) ⇒ Builder
constructor
Public: Constructor.
-
#replace(css_rule, replacement) ⇒ Object
Public: Replace a tag (and its children) from the current document by a string.
Constructor Details
#initialize(document) ⇒ Builder
Public: Constructor.
document - A Nokogiri::XML::Document
13 14 15 |
# File 'lib/genit/builders/builder.rb', line 13 def initialize document @document = document end |
Instance Method Details
#replace(css_rule, replacement) ⇒ Object
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.
28 29 30 31 32 |
# File 'lib/genit/builders/builder.rb', line 28 def replace css_rule, replacement tag = @document.at_css(css_rule) tag.replace replacement @document end |