Class: Pdfh::Month
- Inherits:
-
Object
- Object
- Pdfh::Month
- Defined in:
- lib/pdfh/utils/month.rb
Overview
Handles Month conversions
Constant Summary collapse
- FINDER_3L =
proc { |name_search, month| month[0, 3].casecmp?(name_search) }
- FINDER_FL =
proc { |name_search, month| month.casecmp?(name_search) }
- MONTHS_EN =
rubocop:disable Layout/SpaceInsideArrayPercentLiteral
%w[january february march april may june july august september october november december].freeze
- MONTHS_ES =
%w[enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre].freeze
Class Method Summary collapse
Class Method Details
.normalize_to_i(month) ⇒ Integer
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pdfh/utils/month.rb', line 17 def normalize_to_i(month) # When param is a number month_num = month.to_i raise ArgumentError, "Month #{month.inspect} is not a valid month number" if month_num > 12 return month_num if month_num.between?(1, 12) # When param is a 3 char month: 'mar', 'nov' return find_month(month, FINDER_3L) if month.size == 3 # When param has a direct match find_month(month, FINDER_FL) end |