Class: Clef::Parser::DSL::GroupBuilder

Inherits:
Object
  • Object
show all
Includes:
BlockEvaluation
Defined in:
lib/clef/parser/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(group) ⇒ GroupBuilder

Returns a new instance of GroupBuilder.



85
86
87
# File 'lib/clef/parser/dsl.rb', line 85

def initialize(group)
  @group = group
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Clef::Parser::DSL::BlockEvaluation

Instance Method Details

#staff(id, name: nil, clef: :treble, &block) ⇒ Object

Parameters:

  • id (Symbol)
  • name (String, nil) (defaults to: nil)
  • clef (Symbol) (defaults to: :treble)


92
93
94
95
96
97
# File 'lib/clef/parser/dsl.rb', line 92

def staff(id, name: nil, clef: :treble, &block)
  staff = Clef::Core::Staff.new(id, name: name, clef: Clef::Core::Clef.new(clef))
  evaluate_block(StaffBuilder.new(staff), &block)
  @group.add_staff(staff)
  staff
end