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

Inherits:
Object
  • Object
show all
Defined in:
lib/head_music/style/annotation.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.



52
53
54
55
# File 'lib/head_music/style/annotation.rb', line 52

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.



50
51
52
# File 'lib/head_music/style/annotation.rb', line 50

def guideline_class
  @guideline_class
end

#optionsObject (readonly)

Returns the value of attribute options.



50
51
52
# File 'lib/head_music/style/annotation.rb', line 50

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)


70
71
72
# File 'lib/head_music/style/annotation.rb', line 70

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

#nameObject Also known as: to_s, inspect



74
75
76
# File 'lib/head_music/style/annotation.rb', line 74

def name
  guideline_class.name
end

#new(voice) ⇒ Object



57
58
59
# File 'lib/head_music/style/annotation.rb', line 57

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.



63
64
65
# File 'lib/head_music/style/annotation.rb', line 63

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