class ParseLine::Line
Public Class Methods
add_command(symbol, command)
click to toggle source
# File lib/metronome-odd/parse_line.rb, line 17 def Line.add_command(symbol, command) if @@line_regexp_hash.nil? @@line_regexp_hash = Hash.new([/^$/,[]]) end @@line_regexp_hash[symbol] = command end
new(line)
click to toggle source
# File lib/metronome-odd/parse_line.rb, line 10 def initialize(line) if @@line_regexp_hash.nil? @@line_regexp_hash = Hash.new([/^$/,/^$/]) end @line = line end
Public Instance Methods
parse()
click to toggle source
# File lib/metronome-odd/parse_line.rb, line 24 def parse c = nil s = nil self.remove_separators @@line_regexp_hash.each do |symbol, command_regex| if @line.match(command_regex) c = @line.match(command_regex) s = symbol break end end [s, c] end
remove_separators()
click to toggle source
# File lib/metronome-odd/parse_line.rb, line 6 def remove_separators @line = @line.gsub(/\s+/, "") end