Sha256: 6113880781fc08c3b0a23102a2a6676f00816bcbc0a4ba501218b5e24b0966e7
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true # ******************************************************************************* # OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. # See also https://openstudio.net/license # ******************************************************************************* class String def to_snakecase r = gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase r.gsub!('energy_plus', 'energyplus') r.gsub!('open_studio', 'openstudio') r end def to_camelcase r = split('_').collect(&:capitalize).join r.gsub!('Energyplus', 'EnergyPlus') r.gsub!('Openstudio', 'OpenStudio') r end # simple method to create titles -- very custom to catch known inflections def titleize arr = ['a', 'an', 'the', 'by', 'to'] upcase_arr = ['DX', 'EDA', 'AEDG', 'LPD', 'COP', 'GHLEP', 'ZEDG', 'QAQC', 'PV'] r = tr('_', ' ').gsub(/\w+/) do |match| match_result = match if upcase_arr.include?(match.upcase) match_result = upcase_arr[upcase_arr.index(match.upcase)] elsif arr.include?(match) match_result = match else match_result = match.capitalize end match_result end # fix a couple known camelcase versions r.gsub!('Energyplus', 'EnergyPlus') r.gsub!('Openstudio', 'OpenStudio') r end end # Extend the Git log to add an empty method - for rubocop autocorrect happiness. module Git class Log def empty? size.zero? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openstudio_measure_tester-0.4.0 | lib/openstudio_measure_tester/core_ext.rb |
openstudio_measure_tester-0.3.3 | lib/openstudio_measure_tester/core_ext.rb |