Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/liquid/ext/string.rb
Instance Method Summary collapse
Instance Method Details
#camel_case ⇒ Object
13 14 15 16 |
# File 'lib/liquid/ext/string.rb', line 13 def camel_case return self if self !~ /_/ && self =~ /[A-Z]+.*/ split('_').map{|e| e.capitalize}.join end |
#clean_quote ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/liquid/ext/string.rb', line 4 def clean_quote if index(/["\s]/) %{"#{tr('"', "'")}"} else self end end |
#snake_case ⇒ Object
18 19 20 21 22 23 |
# File 'lib/liquid/ext/string.rb', line 18 def snake_case return downcase if match(/\A[A-Z]+\z/) gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z])([A-Z])/, '\1_\2'). downcase end |