Module: StringPlus

Defined in:
lib/string_plus.rb,
lib/string_plus/version.rb

Constant Summary collapse

VERSION =
"0.3.0"

Instance Method Summary collapse

Instance Method Details

#camelcase(capitalize_first_char = true) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/string_plus.rb', line 4

def camelcase(capitalize_first_char=true)
  res = ""
  flag = capitalize_first_char
  self.each_char {|w|
    (flag = true ; next) if w == "_" || w == " "
    res << if flag
             flag = false
             w.upcase
           else
             w
           end
  }
  res
end

#constantizeObject



23
24
25
# File 'lib/string_plus.rb', line 23

def constantize
  Object.send(:const_get, self.camelcase)
end

#lcamelcaseObject



19
20
21
# File 'lib/string_plus.rb', line 19

def lcamelcase
  camelcase(false)
end