Class: Seiun::Utils
- Inherits:
-
Object
- Object
- Seiun::Utils
- Defined in:
- lib/seiun/utils.rb
Class Method Summary collapse
- .camelize(str) ⇒ Object
- .parsable_date?(str) ⇒ Boolean
- .parsable_time?(str) ⇒ Boolean
- .underscore(str) ⇒ Object
Class Method Details
.camelize(str) ⇒ Object
4 5 6 |
# File 'lib/seiun/utils.rb', line 4 def camelize(str) str.to_s.gsub(/_([a-z])/){|match| $1.upcase } end |
.parsable_date?(str) ⇒ Boolean
12 13 14 |
# File 'lib/seiun/utils.rb', line 12 def parsable_date?(str) str.to_s =~ /^[1-4][0-9]{3}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|3[01])$/ end |
.parsable_time?(str) ⇒ Boolean
16 17 18 |
# File 'lib/seiun/utils.rb', line 16 def parsable_time?(str) str.to_s =~ /^[1-4][0-9]{3}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|3[01])T(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]/ end |
.underscore(str) ⇒ Object
8 9 10 |
# File 'lib/seiun/utils.rb', line 8 def underscore(str) str.to_s.gsub(/([a-z0-9])([A-Z])/){|match| "#{$1}_#{$2.downcase}" } end |