module FlameChannelParser
Constants
- VERSION
Public Class Methods
parse(io)
click to toggle source
Parse a Flame setup into an array of Channel
objects. If a block is given to the method it will yield Channel
objects one by one instead of accumulating them into an array (useful for big setups)
# File lib/flame_channel_parser.rb, line 10 def self.parse(io) c = get_parser_class(io) if block_given? c.new.parse(io, &Proc.new) else c.new.parse(io) end end
parse_file_at(path)
click to toggle source
Parse a Flame setup at passed path. Will return the channels instead of yielding them
# File lib/flame_channel_parser.rb, line 20 def self.parse_file_at(path) File.open(path, &method(:parse)) end
Private Class Methods
get_parser_class(for_io)
click to toggle source
Returns the XML parser class for XML setups
# File lib/flame_channel_parser.rb, line 27 def self.get_parser_class(for_io) tokens = %w( <Setup> <?xml ) current = for_io.pos tokens.each do | token | for_io.rewind return XMLParser if for_io.read(token.size) == token end return Parser ensure for_io.seek(current) end