Class: HitorigotoReporter::Formatter

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

Instance Method Summary collapse

Constructor Details

#initialize(hitorigoto_list) ⇒ Formatter

Returns a new instance of Formatter.



3
4
5
# File 'lib/hitorigoto_reporter/formatter.rb', line 3

def initialize(hitorigoto_list)
  @hitorigoto_list = hitorigoto_list
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/hitorigoto_reporter/formatter.rb', line 7

def empty?
  @hitorigoto_list.empty?
end

#stampsObject



20
21
22
23
# File 'lib/hitorigoto_reporter/formatter.rb', line 20

def stamps
  filtered_list, file_comments = filter_list_and_extract_comments
  filtered_list.flat_map(&:stamps).uniq
end

#to_markdownObject



11
12
13
14
15
16
17
18
# File 'lib/hitorigoto_reporter/formatter.rb', line 11

def to_markdown
  filtered_list, file_comments = filter_list_and_extract_comments

  filtered_list
    .reverse
    .map { |h| "### #{h.username} at [#{h.created_at.strftime('%T')}](#{h.permalink})\n#{format_body(h.text, file_comments)}" }
    .join("\n\n\n")
end