Sha256: 4278452e37721ff7ed9dace116efe1ddf4e09209be373758538604291352fe52
Contents?: true
Size: 669 Bytes
Versions: 1
Compression:
Stored size: 669 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.gsub("\n","") 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.1 | lib/thermal/parser.rb |