Sha256: e8dcded0c5e7fdb83a2a46de812b97fc004c8825c1bbb723296f9b2d839472de
Contents?: true
Size: 655 Bytes
Versions: 1
Compression:
Stored size: 655 Bytes
Contents
require 'nokogiri' module Thermal class Parser attr_accessor :device def initialize(device) @device = device end def process(str) fragment = Nokogiri::HTML.fragment(str).children traverse(fragment) end def traverse(fragment) fragment.map do |node| output = "" if node.class == Nokogiri::XML::Text output << node.content elsif node.class == Nokogiri::XML::Element output << @device.startCode(node.name) output << traverse(node.children) output << @device.endCode(node.name) end output end.join('') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thermal-0.1.0 | lib/thermal/parser.rb |