class StyleStats::Template

Public Class Methods

new(css, options = {}) click to toggle source
# File lib/style_stats/template.rb, line 7
def initialize(css, options = {})
  @css = css
  @options = {format: :default}
  options[:format] = :template if options[:template]
  @options.merge!(options)
end

Public Instance Methods

render() click to toggle source
# File lib/style_stats/template.rb, line 14
def render
  case @options[:format].to_s.to_sym
  when :md, :html
    text = File.read("#{File.dirname(__FILE__)}/templates/#{@options[:format]}.erb")
    ERB.new(text, nil, '-').run(binding)
  when :json
    puts @css.analyze.to_json
  when :template
    text = File.read(@options[:template])
    ERB.new(text, nil, '-').run(binding)
  else
    Table.new(@css.analyze).run
  end
end