class Bookbinder::HtmlDocumentManipulator

Public Instance Methods

read_html_in_tag(document: nil, tag: nil) click to toggle source
# File lib/bookbinder/html_document_manipulator.rb, line 15
def read_html_in_tag(document: nil, tag: nil)
  doc = Nokogiri::HTML(document)
  doc.css(tag).inner_html
end
set_attribute(document: nil, selector: nil, attribute: nil, value: nil) click to toggle source
# File lib/bookbinder/html_document_manipulator.rb, line 5
def set_attribute(document: nil,
                  selector: nil,
                  attribute: nil,
                  value: nil)
  doc = Nokogiri::HTML.fragment(document)
  node_set = doc.css(selector)
  node_set.attr(attribute, value)
  doc.to_html
end