class TreerfulScanner::HtmlPrinter

Attributes

date[R]

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/treerful_scanner/html_printer.rb, line 10
def initialize(*)
  super
  @template = IO.read("#{__dir__}/html_printer/template.erb")
end

Public Instance Methods

print() click to toggle source

Private Instance Methods

tbody() click to toggle source
# File lib/treerful_scanner/html_printer.rb, line 22
def tbody
  "<tbody>#{@time_tables.map(&method(:to_tr)).join}</tbody>"
end
to_tr(time_table) click to toggle source
# File lib/treerful_scanner/html_printer.rb, line 26
def to_tr(time_table)
  result = String.new
  result << "<tr><td><a href=\"https://www.treerful.com/space/#{time_table.place.id}\" rel=\"noopener noreferrer\" target=\"_blank\">#{time_table.place.name}</a></td><td>#{time_table.place.volume}</td>"
  result <<
    binary_form(time_table).each_char.map do |c|
      case c
      when ' ' then '<td></td>'
      when 'O' then '<td class="available"></td>'
      end
    end.join
  result << '</tr>'
end