Class: HeadMusic::Rudiment::Rest

Inherits:
RhythmicElement show all
Includes:
Named
Defined in:
lib/head_music/rudiment/rest.rb

Overview

A Rest represents a period of silence with a specific rhythmic value. It inherits from RhythmicElement and has a duration but no pitch.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from HeadMusic::Rudiment::RhythmicElement

Instance Attribute Details

#alias_name_keysObject (readonly) Originally defined in module Named

Returns the value of attribute alias_name_keys.

#name_keyObject (readonly) Originally defined in module Named

Returns the value of attribute name_key.

Class Method Details

.fetch_or_create(rhythmic_value) ⇒ Object (private)



21
22
23
24
25
# File 'lib/head_music/rudiment/rest.rb', line 21

def self.fetch_or_create(rhythmic_value)
  @rests ||= {}
  hash_key = rhythmic_value.to_s
  @rests[hash_key] ||= new(rhythmic_value)
end

.get(rhythmic_value) ⇒ Object



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

def self.get(rhythmic_value)
  return rhythmic_value if rhythmic_value.is_a?(HeadMusic::Rudiment::Rest)

  rhythmic_value = HeadMusic::Rudiment::RhythmicValue.get(rhythmic_value)
  return nil unless rhythmic_value

  fetch_or_create(rhythmic_value)
end

Instance Method Details

#ensure_localized_name(name:, locale_code: Locale::DEFAULT_CODE, abbreviation: nil) ⇒ Object Originally defined in module Named

#localized_name(locale_code: Locale::DEFAULT_CODE) ⇒ Object Originally defined in module Named

#localized_name_in_default_localeObject (private) Originally defined in module Named

#localized_name_in_locale_matching_language(locale) ⇒ Object (private) Originally defined in module Named

#localized_name_in_matching_locale(locale) ⇒ Object (private) Originally defined in module Named

#localized_namesObject Originally defined in module Named

Returns an array of LocalizedName instances that are synonymous with the name.

#nameObject



27
28
29
# File 'lib/head_music/rudiment/rest.rb', line 27

def name
  "#{rhythmic_value} rest"
end

#name=(name) ⇒ Object Originally defined in module Named

#sounded?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/head_music/rudiment/rest.rb', line 31

def sounded?
  false
end