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. Stands in for a guide class wherever one is expected by answering assess(voice) and assess_items(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?)
-
#assess(voice) ⇒ Object
-
#assess_items(voice) ⇒ Object
-
#categories ⇒ Object
The guide-side twin of GuideAssessment#assessments: one category, so a registry sweep can ask every entry the same question.
-
#category ⇒ Object
-
#composite? ⇒ Boolean
-
#display_name ⇒ Object
-
#guide_items ⇒ Object
-
#hash ⇒ Object
-
#initialize(guide_class, options) ⇒ Configured
constructor
A new instance of Configured.
-
#inspect ⇒ Object
-
#instruction ⇒ Object
An unregistered configuration borrows the instruction of the guide it configures.
-
#items_by_tier ⇒ Object
-
#key ⇒ Object
Reverse lookup, not derivation: an ad-hoc configuration has no key rather than claiming one that resolves to a different configuration.
-
#name ⇒ Object
(also: #to_s)
-
#with(**more) ⇒ Object
Through the guide class, so layering revalidates: .with(contour: :spiral) on an already-configured guide still raises.
Constructor Details
#initialize(guide_class, options) ⇒ Configured
Returns a new instance of Configured.
9 10 11 12 13 |
# File 'lib/head_music/style/guides/configured.rb', line 9 def initialize(guide_class, ) @guide_class = guide_class @options = .dup.freeze guide_items # 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.
7 8 9 |
# File 'lib/head_music/style/guides/configured.rb', line 7 def guide_class @guide_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/head_music/style/guides/configured.rb', line 7 def @options end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
67 68 69 |
# File 'lib/head_music/style/guides/configured.rb', line 67 def ==(other) other.is_a?(self.class) && guide_class == other.guide_class && == other. end |
#assess(voice) ⇒ Object
15 16 17 |
# File 'lib/head_music/style/guides/configured.rb', line 15 def assess(voice) HeadMusic::Style::GuideAssessment.new(self, voice) end |
#assess_items(voice) ⇒ Object
19 20 21 |
# File 'lib/head_music/style/guides/configured.rb', line 19 def assess_items(voice) HeadMusic::Style::Guides::Assessment.assess_items(voice, items_by_tier) end |
#categories ⇒ Object
The guide-side twin of GuideAssessment#assessments: one category, so a registry sweep can ask every entry the same question.
53 54 55 |
# File 'lib/head_music/style/guides/configured.rb', line 53 def categories [category].compact end |
#category ⇒ Object
43 44 45 |
# File 'lib/head_music/style/guides/configured.rb', line 43 def category guide_class.category end |
#composite? ⇒ Boolean
47 48 49 |
# File 'lib/head_music/style/guides/configured.rb', line 47 def composite? false end |
#display_name ⇒ Object
57 58 59 |
# File 'lib/head_music/style/guides/configured.rb', line 57 def display_name key ? HeadMusic::Style::Guide.display_name_for(key) : guide_class.display_name end |
#guide_items ⇒ Object
23 24 25 |
# File 'lib/head_music/style/guides/configured.rb', line 23 def guide_items @guide_items ||= HeadMusic::Style::Guides::Base::TIERS.flat_map { |tier| items_by_tier[tier] }.freeze end |
#hash ⇒ Object
72 73 74 |
# File 'lib/head_music/style/guides/configured.rb', line 72 def hash [guide_class, ].hash end |
#inspect ⇒ Object
81 82 83 |
# File 'lib/head_music/style/guides/configured.rb', line 81 def inspect "#{guide_class.name}.with(#{.inspect})" end |
#instruction ⇒ Object
An unregistered configuration borrows the instruction of the guide it configures.
63 64 65 |
# File 'lib/head_music/style/guides/configured.rb', line 63 def instruction key ? HeadMusic::Style::Guide.instruction_for(key) : guide_class.instruction end |
#items_by_tier ⇒ Object
27 28 29 |
# File 'lib/head_music/style/guides/configured.rb', line 27 def items_by_tier @items_by_tier ||= guide_class.items_by_tier(**) end |
#key ⇒ Object
Reverse lookup, not derivation: an ad-hoc configuration has no key rather than claiming one that resolves to a different configuration.
39 40 41 |
# File 'lib/head_music/style/guides/configured.rb', line 39 def key HeadMusic::Style::Guide.key_for(self) end |
#name ⇒ Object Also known as: to_s
76 77 78 |
# File 'lib/head_music/style/guides/configured.rb', line 76 def name guide_class.name end |
#with(**more) ⇒ Object
Through the guide class, so layering revalidates: .with(contour: :spiral) on an already-configured guide still raises.
33 34 35 |
# File 'lib/head_music/style/guides/configured.rb', line 33 def with(**more) guide_class.with(**.merge(more)) end |