Rename work dates to planned dates

This commit is contained in:
Anton Vakhrushev 2019-11-03 12:06:24 +03:00
parent 991396f68c
commit e236a1bdac
3 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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