Class: Ikku::Reviewer
- Inherits:
-
Object
- Object
- Ikku::Reviewer
- Defined in:
- lib/ikku/reviewer.rb
Instance Method Summary collapse
-
#find(text) ⇒ Ikku::Song
Find one valid song from given text.
-
#initialize(rule: nil) ⇒ Reviewer
constructor
A new instance of Reviewer.
-
#judge(text) ⇒ true, false
Judge if given text is valid song or not.
-
#search(text) ⇒ Array<Array>
Search all valid songs from given text.
Constructor Details
#initialize(rule: nil) ⇒ Reviewer
Returns a new instance of Reviewer.
6 7 8 |
# File 'lib/ikku/reviewer.rb', line 6 def initialize(rule: nil) @rule = rule end |
Instance Method Details
#find(text) ⇒ Ikku::Song
Find one valid song from given text.
12 13 14 15 16 17 18 19 |
# File 'lib/ikku/reviewer.rb', line 12 def find(text) nodes = parser.parse(text) nodes.length.times.find do |index| if (song = Song.new(nodes[index..-1], rule: @rule)).valid? break song end end end |