Calc work hours
This commit is contained in:
@ -1,6 +1,29 @@
|
||||
# TODO: Write documentation for `Dayoff`
|
||||
require "json"
|
||||
|
||||
module Dayoff
|
||||
VERSION = "0.1.0"
|
||||
|
||||
# TODO: Put your code here
|
||||
class WorkDate
|
||||
JSON.mapping(
|
||||
date: String,
|
||||
hours: Int32,
|
||||
)
|
||||
end
|
||||
|
||||
class App
|
||||
def initialize(wh_path)
|
||||
content = File.open(wh_path) do |file|
|
||||
file.gets_to_end
|
||||
end
|
||||
@wdates = Array(WorkDate).from_json(content)
|
||||
end
|
||||
|
||||
def get_work_hours
|
||||
sum = 0
|
||||
@wdates.each do |wd|
|
||||
sum += wd.hours
|
||||
end
|
||||
sum
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user