class Moory::RuleParser::LineReader
Constants
- IGNORE
Attributes
scan_data[R]
Public Class Methods
new()
click to toggle source
# File lib/moory/ruleparser.rb, line 24 def initialize @transitions = Transitions prepare end
Public Instance Methods
<<(string)
click to toggle source
# File lib/moory/ruleparser.rb, line 34 def <<(string) puts(string) end
reset()
click to toggle source
# File lib/moory/ruleparser.rb, line 29 def reset @state = 'origin' @scan_data = {} end
Private Instance Methods
hold(char)
click to toggle source
# File lib/moory/ruleparser.rb, line 55 def hold(char) target(state) << char end
ignore?(char)
click to toggle source
# File lib/moory/ruleparser.rb, line 67 def ignore?(char) IGNORE.include?(char) end
prepare()
click to toggle source
# File lib/moory/ruleparser.rb, line 59 def prepare reset end
putc(char)
click to toggle source
# File lib/moory/ruleparser.rb, line 49 def putc(char) (delimiter?(char) ? issue(char) : hold(char)) unless ignore?(char) end
puts(string)
click to toggle source
# File lib/moory/ruleparser.rb, line 40 def puts(string) string.each_char { |c| putc(c) } scan_data.transform_values do |v| v == '~s~' ? " " : v end end
target(state)
click to toggle source
# File lib/moory/ruleparser.rb, line 63 def target(state) @scan_data.fetch(state.to_sym) { |k| @scan_data[k] = '' } end