Skip to content

Commit

Permalink
Simplified camelize
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarable-iseatz committed Sep 30, 2011
1 parent 852c3b9 commit 9fe22e8
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/protocol_buffers/compiler/file_descriptor_to_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,8 @@ def capfirst(s)
"#{s[0,1].capitalize}#{s[1..-1]}" if s
end

def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
if first_letter_in_uppercase
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
else
lower_case_and_underscored_word.to_s[0].chr.downcase + camelize(lower_case_and_underscored_word)[1..-1]
end
def camelize(lower_case_and_underscored_word)
lower_case_and_underscored_word.to_s.gsub(/(?:^|_)(.)/) { $1.upcase }
end

end

0 comments on commit 9fe22e8

Please sign in to comment.