class Tixriss::Transformer::HTML
Public Instance Methods
body()
click to toggle source
# File lib/tixriss/transformer.rb, line 32 def body <<-EOBODY <body> <table class="table table-striped"> <thead> <tr> <th>From</th> <th>To</th> <th>Text</th> </tr> </thead> <tbody> #{rows.join("\n")} </tbody> </table> </body> EOBODY end
document()
click to toggle source
# File lib/tixriss/transformer.rb, line 28 def document @document ||= Nokogiri::XML(xml) end
header()
click to toggle source
# File lib/tixriss/transformer.rb, line 51 def header <<-EOHEADER <html> <head> <title>Tixriss Report</title> <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet"/> </head> EOHEADER end
links()
click to toggle source
# File lib/tixriss/transformer.rb, line 16 def links rows = document.xpath('//response/answer/link').map(&:to_s) rows.map do |row| node = Nokogiri::XML(row) url_from = node.xpath('//@url.from') url_to = node.xpath('//@url.to') text = node.xpath('//@text') [url_from, url_to, text] end end
rows()
click to toggle source
# File lib/tixriss/transformer.rb, line 9 def rows links.map do |row| data = row.map { |cell| "<td>#{cell}</td>" }.join "<tr>#{data}</tr>" end end
to_s()
click to toggle source
# File lib/tixriss/transformer.rb, line 5 def to_s [header, body, footer].join "\n" end