Module: HarvestWorklog
- Defined in:
- lib/harvest_worklog.rb,
lib/harvest_worklog/version.rb,
lib/harvest_worklog/work_entry_cli.rb
Defined Under Namespace
Classes: CLI, Error, TimeOffCLI, WorkEntryCLI
Constant Summary
collapse
- VERSION =
"0.5.0"
Class Method Summary
collapse
Class Method Details
.dates_between(from, to, holiday_regions:) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/harvest_worklog.rb', line 13
def dates_between(from, to, holiday_regions:)
raise Error, "end date must not be before start date" if to < from
raise Error, "at least one holiday region is required" if holiday_regions.empty?
holidays = Holidays.between(from, to, *(holiday_regions.map { |region| region.downcase.to_sym } + [:observed])).map { |holiday| holiday[:date] }
(from..to).select { |date| date.workday?(holidays:) }
rescue Holidays::InvalidRegion
raise Error, "invalid holiday region: #{holiday_regions.join(", ")}"
end
|
.display_hours(hours) ⇒ Object
23
24
25
|
# File 'lib/harvest_worklog.rb', line 23
def display_hours(hours)
format("%g", hours)
end
|