<commit_before># Copyright (c) 2016 dogatana(<NAME>)

module Kindle
require 'forwardable'

class NavElement
  attr_reader :title, :attr
  attr_accessor :file, :children
  def initialize(title, file = '', children = [], attr = '')
    @title = title
    @file = file
    @attr = attr
    @children = children
  end
  
  def to_s
    title = CGI.escape_html(@title)
    if @file.empty?
      "<span>#{title}</span>"
    else
      %Q[<a href="#{@file}" #{@attr}>#{title}</a>]
    end
  end

  def children?
    @children && !@children.empty?
  end
end

class Nav
  HEAD = <<EOS
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html <commit_msg>rubima.rb では cgi を利用しなくなったのでこちらに require を移動<commit_after># Copyright (c) 2016 dogatana(<NAME>)

require 'forwardable'
require 'cgi'

module Kindle

class NavElement
  attr_reader :title, :attr
  attr_accessor :file, :children
  def initialize(title, file = '', children = [], attr = '')
    @title = title
    @file = file
    @attr = attr
    @children = children
  end
  
  def to_s
    title = CGI.escape_html(@title)
    if @file.empty?
      "<span>#{title}</span>"
    else
      %Q[<a href="#{@file}" #{@attr}>#{title}</a>]
    end
  end

  def children?
    @children && !@children.empty?
  end
end

class Nav
  HEAD = <<EOS
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html 
{'fraction_non_alphanumeric': 0.16145833333333334, 'fraction_numerical': 0.010416666666666666, 'mean_word_length': 3.2563291139240507, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 2, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '160343', 'n_tokens_mistral': 510, 'n_tokens_neox': 487, 'n_words': 127}