Class: Gitara::Node::Stanza
- Inherits:
-
Base
- Object
- Valuable
- Base
- Gitara::Node::Stanza
show all
- Defined in:
- lib/gitara/node/stanza.rb
Instance Attribute Summary
Attributes inherited from Base
#$1
Instance Method Summary
collapse
Methods inherited from Base
#add, #ancestor, #call_value, #children=, #chorded, #definition, #definition?, #definition_children, #definition_name, #definition_of?, #definitions, #descendants, #id, #id_as_word, #inspect, #name, #stanza_version, #value, #voiced_as
Instance Method Details
#bars ⇒ Object
4
5
6
|
# File 'lib/gitara/node/stanza.rb', line 4
def bars
@bars ||= descendants(Node::Bar)
end
|
#heading_for_first_bar ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/gitara/node/stanza.rb', line 17
def heading_for_first_bar
if bars[0].specified_duration
%Q|r#{bars[0].specified_duration}^"#{name}"|
else
ts = ancestor(Node::Tab).time_signature
if ts.generates_whole_note_bars?
%Q|#{ts.rest_bar_value}^"#{name}"|
else
%Q|r#{ts.beat_unit}^"#{name}" | + ("r#{ts.beat_unit} " * (ts.beats_per_bar - 1)).strip
end
end
end
|
#heading_in_lilypond ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/gitara/node/stanza.rb', line 8
def heading_in_lilypond
results = (
[self.heading_for_first_bar] +
bars.drop(1).map(&:stanza_heading)
)
results.join(' ')
end
|