diff --git a/spec/data/work-dates.json b/spec/data/planned-dates.json similarity index 100% rename from spec/data/work-dates.json rename to spec/data/planned-dates.json diff --git a/spec/dayoff_spec.cr b/spec/dayoff_spec.cr index a35f282..c8f1aa9 100644 --- a/spec/dayoff_spec.cr +++ b/spec/dayoff_spec.cr @@ -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 diff --git a/src/dayoff.cr b/src/dayoff.cr index 8295190..18b1afc 100644 --- a/src/dayoff.cr +++ b/src/dayoff.cr @@ -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