Rename work dates to planned dates
This commit is contained in:
parent
991396f68c
commit
e236a1bdac
@ -2,7 +2,7 @@ require "./spec_helper"
|
||||
|
||||
describe Dayoff do
|
||||
it "can calc work hours" do
|
||||
app = Dayoff::App.new("./spec/data/work-dates.json")
|
||||
app = Dayoff::App.new("./spec/data/planned-dates.json")
|
||||
app.get_work_hours.should eq 20
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ require "json"
|
||||
module Dayoff
|
||||
VERSION = "0.1.0"
|
||||
|
||||
class WorkDate
|
||||
class PlannedDate
|
||||
JSON.mapping(
|
||||
date: String,
|
||||
hours: Int32,
|
||||
@ -11,16 +11,16 @@ module Dayoff
|
||||
end
|
||||
|
||||
class App
|
||||
def initialize(wh_path)
|
||||
content = File.open(wh_path) do |file|
|
||||
def initialize(pddates_path)
|
||||
content = File.open(pddates_path) do |file|
|
||||
file.gets_to_end
|
||||
end
|
||||
@wdates = Array(WorkDate).from_json(content)
|
||||
@pdates = Array(PlannedDate).from_json(content)
|
||||
end
|
||||
|
||||
def get_work_hours
|
||||
sum = 0
|
||||
@wdates.each do |wd|
|
||||
@pdates.each do |wd|
|
||||
sum += wd.hours
|
||||
end
|
||||
sum
|
||||
|
Loading…
Reference in New Issue
Block a user