Class: String

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

Instance Method Summary collapse

Instance Method Details

#interval_qualityObject



25
26
27
28
29
30
31
32
33
# File 'lib/core_ext.rb', line 25

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

#match?(*args) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/core_ext.rb', line 21

def match?(*args)
  !!match(*args)
end

#symbolizeObject



35
36
37
# File 'lib/core_ext.rb', line 35

def symbolize
  self.underscore.to_sym
end

#underscoreObject



12
13
14
15
16
17
18
19
# File 'lib/core_ext.rb', line 12

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