Class: IceCube::Validation
- Inherits:
-
Object
- Object
- IceCube::Validation
- Defined in:
- lib/ice_cube/validation.rb
Direct Known Subclasses
DayOfMonthValidation, DayOfWeekValidation, DayOfYearValidation, DayValidation, HourOfDayValidation, MinuteOfHourValidation, MonthOfYearValidation, SecondOfMinuteValidation
Constant Summary collapse
- NUMBER_SUFFIX =
['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th']
- SPECIAL_SUFFIX =
{ 11 => 'th', 12 => 'th', 13 => 'th', 14 => 'th' }
Class Method Summary collapse
- .adjust(goal, date) ⇒ Object
- .nice_numbers(array) ⇒ Object
-
.sentence(array) ⇒ Object
influences by ActiveSupport’s to_sentence.
Class Method Details
.adjust(goal, date) ⇒ Object
8 9 10 11 |
# File 'lib/ice_cube/validation.rb', line 8 def self.adjust(goal, date) return goal if goal.utc_offset == date.utc_offset goal - goal.utc_offset + date.utc_offset end |
.nice_numbers(array) ⇒ Object
23 24 25 26 |
# File 'lib/ice_cube/validation.rb', line 23 def self.nice_numbers(array) array.sort! self.sentence array.map { |d| nice_number(d) } end |
.sentence(array) ⇒ Object
influences by ActiveSupport’s to_sentence
14 15 16 17 18 19 20 21 |
# File 'lib/ice_cube/validation.rb', line 14 def self.sentence(array) case array.length when 0 ; '' when 1 ; array[0].to_s when 2 ; "#{array[0]} and #{array[1]}" else ; "#{array[0...-1].join(', ')}, and #{array[-1]}" end end |