Class: Clef::Parser::DSL::ScoreBuilder
- Inherits:
-
Object
- Object
- Clef::Parser::DSL::ScoreBuilder
show all
- Includes:
- BlockEvaluation
- Defined in:
- lib/clef/parser/dsl.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(plugins: Clef.plugins) ⇒ ScoreBuilder
Returns a new instance of ScoreBuilder.
32
33
34
35
36
37
|
# File 'lib/clef/parser/dsl.rb', line 32
def initialize(plugins: Clef.plugins)
@score = Clef::Core::Score.new
@score.plugins = plugins
@default_group = Clef::Core::StaffGroup.new([], bracket_type: :none)
score.add_staff_group(@default_group)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Clef::Parser::DSL::BlockEvaluation
Instance Attribute Details
#score ⇒ Object
Returns the value of attribute score.
30
31
32
|
# File 'lib/clef/parser/dsl.rb', line 30
def score
@score
end
|
Instance Method Details
77
78
79
|
# File 'lib/clef/parser/dsl.rb', line 77
def build
score
end
|
#composer(value) ⇒ Object
45
46
47
|
# File 'lib/clef/parser/dsl.rb', line 45
def composer(value)
score.composer = value.to_s
end
|
#staff(id, name: nil, clef: :treble, &block) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/clef/parser/dsl.rb', line 59
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)
score.add_staff(staff)
staff
end
|
#staff_group(bracket_type, &block) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/clef/parser/dsl.rb', line 67
def staff_group(bracket_type, &block)
raise Error, "staff_group requires a block" unless block
group = Clef::Core::StaffGroup.new([], bracket_type: bracket_type)
evaluate_block(GroupBuilder.new(group), &block)
score.add_staff_group(group)
group
end
|
#tempo(beat_unit:, bpm:) ⇒ Object
#title(value) ⇒ Object
40
41
42
|
# File 'lib/clef/parser/dsl.rb', line 40
def title(value)
score.title = value.to_s
end
|