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']
Instance Method Summary collapse
- #adjust(goal, date) ⇒ Object
- #nice_numbers(array) ⇒ Object
-
#sentence(array) ⇒ Object
influences by ActiveSupport’s to_sentence.
Instance Method Details
#adjust(goal, date) ⇒ Object
7 8 9 10 |
# File 'lib/ice_cube/validation.rb', line 7 def adjust(goal, date) return goal if goal.utc_offset == date.utc_offset goal - goal.utc_offset + date.utc_offset end |
#nice_numbers(array) ⇒ Object
22 23 24 25 |
# File 'lib/ice_cube/validation.rb', line 22 def nice_numbers(array) array.sort! sentence array.map { |d| nice_number(d) } end |
#sentence(array) ⇒ Object
influences by ActiveSupport’s to_sentence
13 14 15 16 17 18 19 20 |
# File 'lib/ice_cube/validation.rb', line 13 def 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 |