Class: Ikku::Scanner
- Inherits:
-
Object
- Object
- Ikku::Scanner
- Defined in:
- lib/ikku.rb
Overview
Find one haiku that starts from the 1st node of given nodes.
Constant Summary collapse
- DEFAULT_RULE =
[5, 7, 5]
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(nodes, exactly: false, rule: nil) ⇒ Scanner
constructor
A new instance of Scanner.
- #scan ⇒ Object
Constructor Details
#initialize(nodes, exactly: false, rule: nil) ⇒ Scanner
Returns a new instance of Scanner.
50 51 52 53 54 |
# File 'lib/ikku.rb', line 50 def initialize(nodes, exactly: false, rule: nil) @exactly = exactly @nodes = nodes @rule = rule end |
Instance Attribute Details
#count ⇒ Object
Note:
Pronounciation count
57 58 59 |
# File 'lib/ikku.rb', line 57 def count @count ||= 0 end |
Instance Method Details
#scan ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ikku.rb', line 61 def scan if has_valid_first_node? && has_valid_last_node? @nodes.each_with_index do |node, index| if consume(node) if has_full_count? return phrases unless @exactly end else return end end phrases if has_full_count? end end |