Class: HeadMusic::Style::Guides::Configured
- Inherits:
-
Object
- Object
- HeadMusic::Style::Guides::Configured
- Includes:
- TieredItems, ValueEquality
- 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?) included from ValueEquality
- #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 included from TieredItems
- #hash ⇒ Object included from ValueEquality
-
#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.
14 15 16 17 18 |
# File 'lib/head_music/style/guides/configured.rb', line 14 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.
10 11 12 |
# File 'lib/head_music/style/guides/configured.rb', line 10 def guide_class @guide_class end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/head_music/style/guides/configured.rb', line 10 def @options end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql? Originally defined in module ValueEquality
#assess(voice) ⇒ Object
20 21 22 |
# File 'lib/head_music/style/guides/configured.rb', line 20 def assess(voice) HeadMusic::Style::GuideAssessment.new(self, voice) end |
#assess_items(voice) ⇒ Object
24 25 26 |
# File 'lib/head_music/style/guides/configured.rb', line 24 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.
54 55 56 |
# File 'lib/head_music/style/guides/configured.rb', line 54 def categories [category].compact end |
#category ⇒ Object
44 45 46 |
# File 'lib/head_music/style/guides/configured.rb', line 44 def category guide_class.category end |
#composite? ⇒ Boolean
48 49 50 |
# File 'lib/head_music/style/guides/configured.rb', line 48 def composite? false end |
#display_name ⇒ Object
58 59 60 |
# File 'lib/head_music/style/guides/configured.rb', line 58 def display_name key ? HeadMusic::Style::Guide.display_name_for(key) : guide_class.display_name end |
#guide_items ⇒ Object Originally defined in module TieredItems
#hash ⇒ Object Originally defined in module ValueEquality
#inspect ⇒ Object
73 74 75 |
# File 'lib/head_music/style/guides/configured.rb', line 73 def inspect "#{guide_class.name}.with(#{.inspect})" end |
#instruction ⇒ Object
An unregistered configuration borrows the instruction of the guide it configures.
64 65 66 |
# File 'lib/head_music/style/guides/configured.rb', line 64 def instruction key ? HeadMusic::Style::Guide.instruction_for(key) : guide_class.instruction end |
#items_by_tier ⇒ Object
28 29 30 |
# File 'lib/head_music/style/guides/configured.rb', line 28 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.
40 41 42 |
# File 'lib/head_music/style/guides/configured.rb', line 40 def key HeadMusic::Style::Guide.key_for(self) end |
#name ⇒ Object Also known as: to_s
68 69 70 |
# File 'lib/head_music/style/guides/configured.rb', line 68 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.
34 35 36 |
# File 'lib/head_music/style/guides/configured.rb', line 34 def with(**more) guide_class.with(**.merge(more)) end |