Class: Strings::Inflection::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/strings/inflection/parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, count) ⇒ Parser

Returns a new instance of Parser.



18
19
20
21
22
# File 'lib/strings/inflection/parser.rb', line 18

def initialize(str, count)
  @scanner = StringScanner.new(str)
  @count = count
  @value = []
end

Class Method Details

.parse(str, count) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parse a string by evaluating content inside tags



13
14
15
16
# File 'lib/strings/inflection/parser.rb', line 13

def self.parse(str, count)
  parser = new(str, count)
  parser.parse
end

Instance Method Details

#parseObject



24
25
26
27
28
29
30
31
# File 'lib/strings/inflection/parser.rb', line 24

def parse
  while !@scanner.eos?
    parse_noun || parse_verb ||
    parse_count || parse_char
  end

  @value.join
end