Module: StringManip

Defined in:
lib/ycn/string_manip.rb

Instance Method Summary collapse

Instance Method Details

#camel_case(string) ⇒ Object



18
19
20
# File 'lib/ycn/string_manip.rb', line 18

def camel_case string
  camelize string
end

#camelize(string) ⇒ Object



12
13
14
15
16
# File 'lib/ycn/string_manip.rb', line 12

def camelize string
  string.to_s.gsub('_', ' ').split(' ').map { |word|
    word.capitalize
  }.join
end

#low_camelize(string) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ycn/string_manip.rb', line 22

def low_camelize string
  w = 0
  string.gsub('_', ' ').split(' ').map { |word|
    w += 1
    w == 1 ? word.downcase : word.capitalize
  }.join
end

#styled_var(style, variable_name, scope = nil, type = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/ycn/string_manip.rb', line 2

def styled_var style, variable_name, scope=nil, type=nil
  {
  :riki => Proc.new do
    s = scope.to_s.slice(0..0)
    t = type.to_s.slice(0..0)
    "#{s}#{t}".downcase + camelize(variable_name)
  end
  }[style].call
end