Class: String

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

Overview

Stolen from Active Support and changed a bit may in the future be substituted by facets version

Instance Method Summary collapse

Instance Method Details

#interval_qualityObject



16
17
18
19
20
21
22
23
24
# File 'lib/core_ext.rb', line 16

def interval_quality
  {
    'P' => 'Perfect',
    'm' => 'Minor',
    'M' => 'Major',
    'A' => 'Augmented',
    'd' => 'Diminished'
  }[self]
end

#underscoreObject



6
7
8
9
10
11
12
13
14
# File 'lib/core_ext.rb', line 6

def underscore
  return self unless /[A-Z-]|::/.match?(self)
  word = to_s.gsub('::', '/')
  word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
  word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
  word.tr!('- ', '_')
  word.downcase!
  word
end