Class: TimetrapHarvest::Output

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

Constant Summary collapse

LINE_DIVIDER =
'-' * 80
SUBMITTED_HEADER =
"Submitted entries\n#{LINE_DIVIDER}"
FAILED_HEADER =
"Failed entries\n#{LINE_DIVIDER}"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(results = {}) ⇒ Output

Returns a new instance of Output.



8
9
10
# File 'lib/timetrap_harvest/output.rb', line 8

def initialize(results = {})
  @results = results
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

Instance Method Details

#generateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/timetrap_harvest/output.rb', line 12

def generate
  messages = [stats]

  unless .empty?
    messages << 
    messages += .map { || success_message([:notes]) }
    messages << "\n"
  end

  unless failed.empty?
    messages << FAILED_HEADER
    messages += failed.map { |failed| failed_message(failed[:note], failed[:error]) }
    messages << "\n"
  end

  messages.join("\n")
end