Method: String#to_camel!

Defined in:
lib/revent/amf3/util/string.rb

#to_camel!Object

Aryk: This might be a better way of writing it. I made a lightweight version to use in my modifications. Feel free to adapt this to the rest.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/revent/amf3/util/string.rb', line 15

def to_camel! # no one should change these unless they can benchmark and prove their way is faster. =)
  @cached_camel_strings ||= {}
  @cached_camel_strings[self] ||= (
    # new_string = self.dup # need to do this since sometimes the string is frozen
    while x = index("_")
      y=x+1
      self[x..y] = self[y..y].capitalize # in my tests, it was faster than upcase
    end
    self
  )
end