class String
Public Instance Methods
camelize2()
click to toggle source
# File lib/scale.rb, line 77 def camelize2 self.split('_').collect(&:upcase_first).join end
constantize2()
click to toggle source
# File lib/common.rb, line 32 def constantize2 Object.const_get(self) end
hex_to_bytes()
click to toggle source
# File lib/common.rb, line 36 def hex_to_bytes data = self.start_with?('0x') ? self[2..] : self raise "Not valid hex string" if data.length % 2 != 0 data.scan(/../).map(&:hex) end
underscore2()
click to toggle source
# File lib/scale.rb, line 81 def underscore2 self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end
upcase_first()
click to toggle source
# File lib/scale.rb, line 73 def upcase_first self.sub(/\S/, &:upcase) end