Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Instance Method Summary collapse
Instance Method Details
#date_to_ary ⇒ Array
16 17 18 |
# File 'lib/core_ext/string.rb', line 16 def date_to_ary self.split("〜").map!(&:parse_date) end |
#parse_date ⇒ Date
6 7 8 9 10 11 12 13 |
# File 'lib/core_ext/string.rb', line 6 def parse_date self.scan(/(\d+)(月)(\d+)(日)/) month = $1.to_i day = $3.to_i today = Date.today year = today.month >= 10 && month == 1 ? today.year + 1 : today.year Date.parse("#{year}.#{month}.#{day}") end |
#phone_number? ⇒ Boolean
20 21 22 |
# File 'lib/core_ext/string.rb', line 20 def phone_number? delete('-') =~ /^\d+$/ end |