Sha256: 34743e70973bef0ca85cfac69e5aa39d84b2e0df3f855cf13cd8b83aab006a46
Contents?: true
Size: 545 Bytes
Versions: 16
Compression:
Stored size: 545 Bytes
Contents
module OwaspZap # extending String instance module StringExtension # from camel_case to snake_case: ie: fooBar to foo_bar 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 # from snake_case to camel_case: ie: foo_bar to fooBar def camel_case self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join end end end
Version data entries
16 entries across 16 versions & 1 rubygems