module Utilise::Augment::Modify
Extends classes that could be modified
Public Instance Methods
camel(first_letter = :upper)
click to toggle source
Return a string in modified camel case
# File lib/utilise/augment/modify.rb, line 6 def camel(first_letter = :upper) array = split_up case first_letter when :upper array.map(&:capitalize).join when :lower array.first + array[1..-1].map(&:capitalize).join end end
kebab()
click to toggle source
Returns a string in kebab case
# File lib/utilise/augment/modify.rb, line 27 def kebab split_up.join('-') end
snake()
click to toggle source
Return a string in snake case
# File lib/utilise/augment/modify.rb, line 17 def snake split_up.join('_') end
space()
click to toggle source
Return a string in regular space case
# File lib/utilise/augment/modify.rb, line 22 def space split_up.join(' ') end
Private Instance Methods
split_up()
click to toggle source
Splits up the current string into an array and normalises it
# File lib/utilise/augment/modify.rb, line 34 def split_up regex = /(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?=[-_ ])/ arr = to_s.split(regex) arr.map!(&:downcase) arr.map!(&:strip) arr.map! { |s| s.delete('_') } arr.map { |s| s.delete('-') } end