Method: GRPC::GenericService.underscore
- Defined in:
- src/ruby/lib/grpc/generic/service.rb
.underscore(s) ⇒ Object
creates a new string that is the underscore separate version of s.
E.g, PrintHTML -> print_html AMethod -> a_method AnRpc -> an_rpc
33 34 35 36 37 38 39 40 |
# File 'src/ruby/lib/grpc/generic/service.rb', line 33 def self.underscore(s) s = +s # Avoid mutating the argument, as it might be frozen. s.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') s.gsub!(/([a-z\d])([A-Z])/, '\1_\2') s.tr!('-', '_') s.downcase! s end |