Class: FlameChannelParser::Parser2011
- Inherits:
-
Object
- Object
- FlameChannelParser::Parser2011
- Defined in:
- lib/parser_2011.rb
Overview
Basic parser used for setups from versions up to 2011
Direct Known Subclasses
Defined Under Namespace
Constant Summary
- CHANNEL_MATCHER =
/Channel (.+)\n/- NODE_TYPE_MATCHER =
/Node (\w+)/- NODE_NAME_MATCHER =
/Name (\w+)/
Instance Method Summary (collapse)
-
- (Boolean) channel_is_useful?(channel_name)
Override this method to skip some channels, this will speedup your code alot.
- - (Object) create_key
-
- (Object) matchers
Defines a number of regular expression matchers applied to the file as it is being parsed.
- - (Object) parse(io)
Instance Method Details
- (Boolean) channel_is_useful?(channel_name)
Override this method to skip some channels, this will speedup your code alot
156 157 158 |
# File 'lib/parser_2011.rb', line 156 def channel_is_useful?(channel_name) true end |
- (Object) create_key
34 35 36 |
# File 'lib/parser_2011.rb', line 34 def create_key Key.new end |
- (Object) matchers
Defines a number of regular expression matchers applied to the file as it is being parsed
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/parser_2011.rb', line 22 def matchers [ [:frame, :to_i, /Frame ([\-\d\.]+)/], [:value, :to_f, /Value ([\-\d\.]+)/], [:left_slope, :to_f, /LeftSlope ([\-\d\.]+)/], [:right_slope, :to_f, /RightSlope ([\-\d\.]+)/], [:interpolation, :to_s, /Interpolation (\w+)/], [:extrapolation, :to_s, /Extrapolation (\w+)/], [:break_slope, :to_s, /BreakSlope (\w+)/] ] end |
- (Object) parse(io)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/parser_2011.rb', line 137 def parse(io) channels = [] node_name, node_type = nil, nil until io.eof? line = io.gets if line =~ NODE_TYPE_MATCHER node_type = $1 elsif line =~ NODE_NAME_MATCHER node_name = $1 elsif line =~ CHANNEL_MATCHER && channel_is_useful?($1) channels << Channel.new(io, $1, self, node_type, node_name) end end channels end |