Class: GithubDailyDigest::HtmlFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/html_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, options = {}) ⇒ HtmlFormatter

Returns a new instance of HtmlFormatter.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/html_formatter.rb', line 8

def initialize(data, options = {})
  @data = normalize_data(data)
  @output_file = options[:output_file] || generate_default_filename
  @theme = options[:theme] || 'default' # Can be 'default', 'dark', or 'light'
  @chart_theme = options[:chart_theme] || 'default' # Can customize chart colors
  @title = options[:title] || "GitHub Daily Digest - #{Time.now.strftime('%Y-%m-%d')}"
  @show_charts = options.key?(:show_charts) ? options[:show_charts] : true
  @show_extended = options.key?(:show_extended) ? options[:show_extended] : true
  @show_repo_details = options.key?(:show_repo_details) ? options[:show_repo_details] : true
  @show_language_details = options.key?(:show_language_details) ? options[:show_language_details] : true
  @show_work_details = options.key?(:show_work_details) ? options[:show_work_details] : true
  @raw_data = options[:raw_data] # Store raw data for later use
end

Instance Attribute Details

#data ⇒ Object (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/html_formatter.rb', line 6

def data
  @data
end

#output_file ⇒ Object (readonly)

Returns the value of attribute output_file.



6
7
8
# File 'lib/html_formatter.rb', line 6

def output_file
  @output_file
end

#theme ⇒ Object (readonly)

Returns the value of attribute theme.



6
7
8
# File 'lib/html_formatter.rb', line 6

def theme
  @theme
end

Instance Method Details

#generate ⇒ Object



22
23
24
25
26
27
# File 'lib/html_formatter.rb', line 22

def generate
  html_content = build_html
  File.write(output_file, html_content)
  puts "HTML report generated at: #{output_file}"
  output_file
end