Module: MIDIEvents::Constant::Name

Extended by:
Name
Included in:
Name
Defined in:
lib/midi-events/constant.rb

Instance Method Summary collapse

Instance Method Details

#match?(key, other) ⇒ Boolean

Parameters:

  • key (Symbol, String)
  • other (Symbol, String)

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/midi-events/constant.rb', line 36

def match?(key, other)
  match_key = key.to_s.downcase
  [match_key, Name.underscore(match_key)].include?(other.to_s.downcase)
end

#underscore(string) ⇒ String

eg “Control Change” -> “control_change”

Parameters:

  • string (Symbol, String)

Returns:

  • (String)


29
30
31
# File 'lib/midi-events/constant.rb', line 29

def underscore(string)
  string.to_s.downcase.gsub(/(\ )+/, '_')
end