Method: String#to_underscore

Defined in:
lib/bcl/core_ext.rb

#to_underscoreObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bcl/core_ext.rb', line 7

def to_underscore
  gsub('OpenStudio', 'Openstudio')
    .gsub('EnergyPlus', 'Energyplus')
    .gsub(/::/, '/')
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .tr('-', '_')
    .tr(' ', '_')
    .squeeze('_')
    .downcase
end