Class: HeadMusic::Style::Annotation::Configured

Inherits:
Object
  • Object
show all
Defined in:
lib/head_music/style/annotation/configured.rb

Overview

A RULESET entry pairing a guideline class with configuration. Quacks like a class to the analyze loop by responding to #new(voice).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(guideline_class, options) ⇒ Configured

Returns a new instance of Configured.



7
8
9
10
# File 'lib/head_music/style/annotation/configured.rb', line 7

def initialize(guideline_class, options)
  @guideline_class = guideline_class
  @options = options
end

Instance Attribute Details

#guideline_classObject (readonly)

Returns the value of attribute guideline_class.



5
6
7
# File 'lib/head_music/style/annotation/configured.rb', line 5

def guideline_class
  @guideline_class
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/head_music/style/annotation/configured.rb', line 5

def options
  @options
end

Instance Method Details

#default_gate?Boolean

Mirrors the class-level predicate so build-time RULESET filters can classify any entry (bare class or configured) uniformly. A per-entry gate: option takes precedence over the guideline class’s default.

Returns:

  • (Boolean)


25
26
27
# File 'lib/head_music/style/annotation/configured.rb', line 25

def default_gate?
  options.fetch(:gate, guideline_class.default_gate?)
end

#nameObject Also known as: to_s, inspect



29
30
31
# File 'lib/head_music/style/annotation/configured.rb', line 29

def name
  guideline_class.name
end

#new(voice) ⇒ Object



12
13
14
# File 'lib/head_music/style/annotation/configured.rb', line 12

def new(voice)
  guideline_class.new(voice, **options)
end

#with(**more) ⇒ Object

Layers additional options onto an already-configured entry, e.g. MinimumNotes.with(5).with(gate: true), without dropping prior options.



18
19
20
# File 'lib/head_music/style/annotation/configured.rb', line 18

def with(**more)
  Configured.new(guideline_class, options.merge(more))
end