calc_working_hours 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59b2fa0cfd4ca5f6a4d76708ec33d08c66fcfc2f
4
- data.tar.gz: 28b1ce51ffe176c2da96ae854cec39ecb05a057e
3
+ metadata.gz: ea21e50f8b5b8af5843d898a5019f54bd5e4c4d0
4
+ data.tar.gz: 5eb6efc9ff0decf4ca6348c62007ddad425d82cb
5
5
  SHA512:
6
- metadata.gz: 741b6c8c747df2d3732f5e387df7daab5d22668d10034f5ea37cc75117d6f6f7ba24038d0e5f21ab5394705e366b518bd84c2d7a3571c750f03749b583d63633
7
- data.tar.gz: 76d9ec1e42ac1e42acf2e50074a0e4ebc2f06086f2c347d14c6c7f6f2d195243b64e94ac6f945fff874335f7c3576cb78fc0f51ca572373b2a48bc54fc102681
6
+ metadata.gz: 16e476bd0df661b86ecf69877ca07adbf3e12ef4f14cee526d120247f3dff77b30a0e771542b8d596211333378d06a204f4543a652fd787933ecc546fdf099a6
7
+ data.tar.gz: 2c9b9ca198e8b52abffe72ce7718ddc022163947fe30cd43ce912926a47058c41954459c1a9a78b45bc37f2d7ff917fb349675fde7bdade764f6b3da1e309a07
@@ -45,5 +45,9 @@ module CalcWorkingHours
45
45
  return WorkingHours.new("0:00").add_array_time(array_of_working_hours_in_range).time_string
46
46
  end
47
47
 
48
+ def total_night_time
49
+ self.total_working_hours_in_range("22:00", "29:00")
50
+ end
51
+
48
52
  end
49
53
  end
@@ -5,7 +5,7 @@ require "date"
5
5
  module CalcWorkingHours
6
6
 
7
7
  class TimeCardRow
8
- attr_reader :starting_time, :ending_time, :break_time, :working_hours, :date_string, :time_point, :working_hours_in_range, :over_time, :id
8
+ attr_reader :starting_time, :ending_time, :break_time, :working_hours, :date_string, :time_point, :over_time, :id
9
9
  def initialize(date_string, starting_time, ending_time, *break_time)
10
10
  unless date_string.class == String
11
11
  raise "failure set_date (date should string class)! TimeCardRow class"
@@ -84,7 +84,12 @@ module CalcWorkingHours
84
84
  array_of_working_hours << WorkingHours.new(ending_time).minus_time(starting_time).time_string
85
85
  end
86
86
  end
87
- return @working_hours_in_range = WorkingHours.new("0:00").add_array_time(array_of_working_hours).time_string
87
+ return WorkingHours.new("0:00").add_array_time(array_of_working_hours).time_string
88
88
  end
89
+
90
+ def between_10pm_and_5am
91
+ self.working_hours_in_range("22:00", "29:00")
92
+ end
93
+
89
94
  end
90
95
  end
@@ -1,3 +1,3 @@
1
1
  module CalcWorkingHours
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -44,7 +44,6 @@ describe TimeCardRow do
44
44
  it "所定労働時間を8:20とすると、残業時間は0:00となる" do
45
45
  @time_card_row.set_fixed_working_hours("8:20").over_time.time_string.should == "0:00"
46
46
  end
47
-
48
47
  end
49
48
 
50
49
  context "始業11:30、終業23:34、休憩15:38〜17:14のとき" do
@@ -103,7 +102,18 @@ describe TimeCardRow do
103
102
  it "始業8:00、終業19:00、休憩7:00〜11:00は時系列が誤っているので、エラーが発生すること" do
104
103
  proc { TimeCardRow.new("2013/5/12", "8:00", "19:00", ["7:00", "10:00"]) }.should raise_error
105
104
  end
105
+ end
106
+
107
+ context "始業20:00、終業25:00のとき" do
108
+ it "深夜勤務時間は3:00となる" do
109
+ TimeCardRow.new("2013/5/12", "20:00", "25:00").between_10pm_and_5am.should == "3:00"
110
+ end
111
+ end
106
112
 
113
+ context "始業20:00、終業25:00、休憩23:00〜24:00のとき" do
114
+ it "深夜勤務時間は4:00となる" do
115
+ TimeCardRow.new("2013/5/12", "20:00", "25:00", ["23:00", "24:00"]).between_10pm_and_5am.should == "2:00"
116
+ end
107
117
  end
108
118
 
109
119
  end
@@ -14,6 +14,18 @@ describe TimeCard do
14
14
  it "残業時間のトータルは2:00となる" do
15
15
  @time_card.total_over_time.should == "2:00"
16
16
  end
17
+ end
17
18
 
19
+ context "始業24:00、終業30:00、休憩25:00〜26:00が2日間のとき" do
20
+ before do
21
+ @time_card = TimeCard.new(1,1)
22
+ @time_card.add_row(TimeCardRow.new("2013/5/12", "24:00", "30:00",["25:00", "26:00"]).set_fixed_working_hours("7:00"))
23
+ @time_card.add_row(TimeCardRow.new("2013/5/13", "24:00", "30:00",["25:00", "26:00"]).set_fixed_working_hours("7:00"))
24
+ end
25
+
26
+ it "深夜時間のトータルは8:00となる" do
27
+ @time_card.total_night_time.should == "8:00"
28
+ end
18
29
  end
30
+
19
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calc_working_hours
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi_U
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2013-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler