Class: DynarexParser
- Inherits:
-
Object
- Object
- DynarexParser
- Defined in:
- lib/dynarex-parser.rb
Instance Method Summary collapse
-
#initialize(s) ⇒ DynarexParser
constructor
A new instance of DynarexParser.
- #to_a ⇒ Object
Constructor Details
#initialize(s) ⇒ DynarexParser
Returns a new instance of DynarexParser.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dynarex-parser.rb', line 9 def initialize(s) schema = s[/schema>([^<]+)/,1] record_name, raw_fields = schema.match(/(\w+)\(([^\(]+)\)$/).captures error_found = raw_fields.split(',').include? record_name raise "record name must not match a field name" if error_found @a = parse(s.split(/(?=<!--)/).map {|x| x.sub(/<!--.*-->/m,'')}.join) end |
Instance Method Details
#to_a ⇒ Object
20 21 22 |
# File 'lib/dynarex-parser.rb', line 20 def to_a() @a end |