ice_cube 0.2.8.1 → 0.2.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ice_cube/validation_types.rb +8 -8
- data/lib/ice_cube/version.rb +1 -1
- metadata +2 -2
@@ -2,7 +2,7 @@ module ValidationTypes
|
|
2
2
|
|
3
3
|
def second_of_minute(*seconds)
|
4
4
|
@validations[:second_of_minute] ||= []
|
5
|
-
@validation_types[:second_of_minute] ||= SecondOfMinuteValidation.new(self)
|
5
|
+
@validation_types[:second_of_minute] ||= IceCube::SecondOfMinuteValidation.new(self)
|
6
6
|
seconds.each do |second|
|
7
7
|
raise ArgumentError.new('Argument must be a valid second') unless second < 60 && second >= 0
|
8
8
|
@validations[:second_of_minute] << second
|
@@ -17,7 +17,7 @@ module ValidationTypes
|
|
17
17
|
# occurs every monday.
|
18
18
|
def day(*days)
|
19
19
|
@validations[:day] ||= []
|
20
|
-
@validation_types[:day] ||= DayValidation.new(self)
|
20
|
+
@validation_types[:day] ||= IceCube::DayValidation.new(self)
|
21
21
|
days.each do |day|
|
22
22
|
if day.is_a?(Integer)
|
23
23
|
# integer type argument
|
@@ -40,7 +40,7 @@ module ValidationTypes
|
|
40
40
|
# Note: you cannot combine month_of_year and day_of_year in the same rule.
|
41
41
|
def day_of_year(*days)
|
42
42
|
@validations[:day_of_year] ||= []
|
43
|
-
@validation_types[:day_of_year] ||= DayOfYearValidation.new(self)
|
43
|
+
@validation_types[:day_of_year] ||= IceCube::DayOfYearValidation.new(self)
|
44
44
|
days.each do |day|
|
45
45
|
raise ArgumentError.new('Argument must be a valid day') if day.abs > 366
|
46
46
|
raise ArgumentError.new('Argument must be non-zero') if day == 0
|
@@ -57,7 +57,7 @@ module ValidationTypes
|
|
57
57
|
# Note: you cannot combine day_of_year and month_of_year in the same rule.
|
58
58
|
def month_of_year(*months)
|
59
59
|
@validations[:month_of_year] ||= []
|
60
|
-
@validation_types[:month_of_year] ||= MonthOfYearValidation.new(self)
|
60
|
+
@validation_types[:month_of_year] ||= IceCube::MonthOfYearValidation.new(self)
|
61
61
|
months.each do |month|
|
62
62
|
if month.is_a?(Integer)
|
63
63
|
# integer type argument
|
@@ -80,7 +80,7 @@ module ValidationTypes
|
|
80
80
|
def day_of_week(days)
|
81
81
|
puts days[0].to_s
|
82
82
|
@validations[:day_of_week] ||= {}
|
83
|
-
@validation_types[:day_of_week] ||= DayOfWeekValidation.new(self)
|
83
|
+
@validation_types[:day_of_week] ||= IceCube::DayOfWeekValidation.new(self)
|
84
84
|
days.each do |day, occurrences|
|
85
85
|
unless day.is_a?(Integer)
|
86
86
|
raise ArgumentError.new('Argument must be a valid day of week') unless IceCube::DAYS.has_key?(day)
|
@@ -97,7 +97,7 @@ module ValidationTypes
|
|
97
97
|
|
98
98
|
def hour_of_day(*hours)
|
99
99
|
@validations[:hour_of_day] ||= []
|
100
|
-
@validation_types[:hour_of_day] ||= HourOfDayValidation.new(self)
|
100
|
+
@validation_types[:hour_of_day] ||= IceCube::HourOfDayValidation.new(self)
|
101
101
|
hours.each do |hour|
|
102
102
|
raise ArgumentError.new('Argument must be a valid hour') unless hour < 24 && hour >= 0
|
103
103
|
@validations[:hour_of_day] << hour
|
@@ -112,7 +112,7 @@ module ValidationTypes
|
|
112
112
|
# this rule should occur on the first and last day of every month.
|
113
113
|
def day_of_month(*days)
|
114
114
|
@validations[:day_of_month] ||= []
|
115
|
-
@validation_types[:day_of_month] ||= DayOfMonthValidation.new(self)
|
115
|
+
@validation_types[:day_of_month] ||= IceCube::DayOfMonthValidation.new(self)
|
116
116
|
days.each do |day|
|
117
117
|
raise ArgumentError.new('Argument must be a valid date') if day.abs > 31
|
118
118
|
raise ArgumentError.new('Argument must be non-zero') if day == 0
|
@@ -125,7 +125,7 @@ module ValidationTypes
|
|
125
125
|
|
126
126
|
def minute_of_hour(*minutes)
|
127
127
|
@validations[:minute_of_hour] ||= []
|
128
|
-
@validation_types[:minute_of_hour] ||= MinuteOfHourValidation.new(self)
|
128
|
+
@validation_types[:minute_of_hour] ||= IceCube::MinuteOfHourValidation.new(self)
|
129
129
|
minutes.each do |minute|
|
130
130
|
raise ArgumentError.new('Argument must be a valid minute') unless minute < 60 && minute >= 0
|
131
131
|
@validations[:minute_of_hour] << minute
|
data/lib/ice_cube/version.rb
CHANGED