Class: HeadMusic::Style::Guides::Configured
- Inherits:
-
Object
- Object
- HeadMusic::Style::Guides::Configured
- Defined in:
- lib/head_music/style/guides/configured.rb
Overview
A guide class paired with configuration. Quacks like a guide class to Style::Analysis by responding to #analyze(voice), exactly as Annotation::Configured quacks like a guideline class via #new(voice).
Instance Attribute Summary collapse
-
#guide_class ⇒ Object
readonly
Returns the value of attribute guide_class.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
-
#analyze(voice) ⇒ Object
-
#category ⇒ Object
-
#display_name ⇒ Object
-
#hash ⇒ Object
-
#initialize(guide_class, options) ⇒ Configured
constructor
A new instance of Configured.
-
#inspect ⇒ Object
-
#key ⇒ Object
Reverse lookup, not derivation.
-
#name ⇒ Object
(also: #to_s)
-
#ruleset ⇒ Object
-
#with(**more) ⇒ Object
Re-dispatches through the guide class so layering revalidates: ContourMelody.with(contour: :arch).with(contour: :spiral) still raises.
Constructor Details
#initialize(guide_class, options) ⇒ Configured
Returns a new instance of Configured.
10 11 12 13 14 |
# File 'lib/head_music/style/guides/configured.rb', line 10 def initialize(guide_class, ) @guide_class = guide_class @options = .dup.freeze ruleset # Resolve now, so a bad configuration raises here rather than mid-grading. end |
Instance Attribute Details
#guide_class ⇒ Object (readonly)
Returns the value of attribute guide_class.
8 9 10 |
# File 'lib/head_music/style/guides/configured.rb', line 8 def guide_class @guide_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/head_music/style/guides/configured.rb', line 8 def @options end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
45 46 47 |
# File 'lib/head_music/style/guides/configured.rb', line 45 def ==(other) other.is_a?(self.class) && guide_class == other.guide_class && == other. end |
#analyze(voice) ⇒ Object
16 17 18 |
# File 'lib/head_music/style/guides/configured.rb', line 16 def analyze(voice) ruleset.map { |rule| rule.new(voice) } end |
#category ⇒ Object
37 38 39 |
# File 'lib/head_music/style/guides/configured.rb', line 37 def category guide_class.category end |
#display_name ⇒ Object
41 42 43 |
# File 'lib/head_music/style/guides/configured.rb', line 41 def display_name key ? HeadMusic::Style::Guide.display_name_for(key) : guide_class.display_name end |
#hash ⇒ Object
50 51 52 |
# File 'lib/head_music/style/guides/configured.rb', line 50 def hash [guide_class, ].hash end |
#inspect ⇒ Object
59 60 61 |
# File 'lib/head_music/style/guides/configured.rb', line 59 def inspect "#{guide_class.name}.with(#{.inspect})" end |
#key ⇒ Object
Reverse lookup, not derivation. An ad-hoc configuration outside the registry honestly has no key rather than claiming a key that resolves to a different configuration.
33 34 35 |
# File 'lib/head_music/style/guides/configured.rb', line 33 def key HeadMusic::Style::Guide.key_for(self) end |
#name ⇒ Object Also known as: to_s
54 55 56 |
# File 'lib/head_music/style/guides/configured.rb', line 54 def name guide_class.name end |
#ruleset ⇒ Object
20 21 22 |
# File 'lib/head_music/style/guides/configured.rb', line 20 def ruleset @ruleset ||= guide_class.ruleset(**) end |
#with(**more) ⇒ Object
Re-dispatches through the guide class so layering revalidates: ContourMelody.with(contour: :arch).with(contour: :spiral) still raises.
26 27 28 |
# File 'lib/head_music/style/guides/configured.rb', line 26 def with(**more) guide_class.with(**.merge(more)) end |