Sha256: 9ec270c1119c1b4325c9776d96c401011b4bd6a2270e22b87518b1084fb23303

Contents?: true

Size: 923 Bytes

Versions: 9

Compression:

Stored size: 923 Bytes

Contents

module Snuffle
  module Formatters

    class HtmlIndex

      include Formatters::Base

      attr_accessor :summaries, :start_path

      def initialize(summaries, start_path)
        self.summaries = summaries.sort{|a,b| a.cohorts.count <=> b.cohorts.count}.reverse
        self.start_path = start_path
      end

      def header
        ["File", "Class", "Object Candidates"].map{|col| "<th>#{col.titleize}</th>"}.join("\r\n")
      end

      def content
        Haml::Engine.new(output_template).render(
          Object.new, {
            summaries: self.summaries,
            start_path: self.start_path,
            date: Time.now.strftime("%Y/%m/%d"),
            time: Time.now.strftime("%l:%M %P")
          }
        )
      end

      def filename
        "index.htm"
      end

      def output_template
        File.read(File.dirname(__FILE__) + "/templates/index.html.haml")
      end

    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
snuffle-0.14.2 lib/snuffle/formatters/html_index.rb
snuffle-0.14.1 lib/snuffle/formatters/html_index.rb
snuffle-0.14.0 lib/snuffle/formatters/html_index.rb
snuffle-0.13.0 lib/snuffle/formatters/html_index.rb
snuffle-0.12.2 lib/snuffle/formatters/html_index.rb
snuffle-0.12.1 lib/snuffle/formatters/html_index.rb
snuffle-0.12.0 lib/snuffle/formatters/html_index.rb
snuffle-0.11.1 lib/snuffle/formatters/html_index.rb
snuffle-0.10.1 lib/snuffle/formatters/html_index.rb