Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/textpeg2rubypeg.rb

Instance Method Summary collapse

Instance Method Details

#to_class_nameObject



5
6
7
8
# File 'lib/textpeg2rubypeg.rb', line 5

def to_class_name
  # Taken from ActiveSupport inflector
  self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end

#to_method_nameObject



10
11
12
13
14
15
16
17
# File 'lib/textpeg2rubypeg.rb', line 10

def to_method_name
  # Taken from ActiveSupport inflector
  self.gsub(/::/, '/').
     gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
     gsub(/([a-z\d])([A-Z])/,'\1_\2').
     tr("-", "_").
     downcase
end