Class: TimetrapToggl::Output
- Inherits:
-
Object
- Object
- TimetrapToggl::Output
- Defined in:
- lib/timetrap_toggl/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
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(results, projects) ⇒ Output
constructor
A new instance of Output.
Constructor Details
#initialize(results, projects) ⇒ Output
Returns a new instance of Output.
8 9 10 11 |
# File 'lib/timetrap_toggl/output.rb', line 8 def initialize(results, projects) @results = results @projects = projects end |
Instance Attribute Details
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
6 7 8 |
# File 'lib/timetrap_toggl/output.rb', line 6 def projects @projects end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
6 7 8 |
# File 'lib/timetrap_toggl/output.rb', line 6 def results @results end |
Instance Method Details
#generate ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/timetrap_toggl/output.rb', line 13 def generate = [stats] unless submitted.empty? << SUBMITTED_HEADER += submitted.map do |submitted| project = projects.find { |p| p["id"] == submitted["pid"] } ("#{project["name"]} - #{submitted["description"]}") end << "\n" end unless failed.empty? << FAILED_HEADER += failed.map do |failed| project = projects.find { |p| p["id"] == failed["pid"] } (failed[:note], failed[:error]) end << "\n" end .join("\n") end |