Class: Ikku::Song
- Inherits:
-
Object
- Object
- Ikku::Song
- Defined in:
- lib/ikku/song.rb
Constant Summary collapse
- DEFAULT_RULE =
[5, 7, 5]
Instance Method Summary collapse
-
#initialize(nodes, exactly: false, rule: nil) ⇒ Song
constructor
A new instance of Song.
- #phrases ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(nodes, exactly: false, rule: nil) ⇒ Song
Returns a new instance of Song.
8 9 10 11 12 |
# File 'lib/ikku/song.rb', line 8 def initialize(nodes, exactly: false, rule: nil) @exactly = exactly @nodes = nodes @rule = rule end |
Instance Method Details
#phrases ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ikku/song.rb', line 14 def phrases if instance_variable_defined?(:@phrases) @phrases else @phrases = scan end end |
#valid? ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ikku/song.rb', line 22 def valid? case when phrases.nil? false when has_odd_parentheses? false else true end end |