Class: Kaitai::Struct::Visualizer::Parser
- Inherits:
-
Object
- Object
- Kaitai::Struct::Visualizer::Parser
- Defined in:
- lib/kaitai/struct/visualizer/parser.rb
Overview
Base class for everything that deals with compiling .ksy and parsing stuff as object tree.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(compiler, bin_fn, formats_fn, opts) ⇒ Parser
constructor
A new instance of Parser.
- #load ⇒ Object
Constructor Details
#initialize(compiler, bin_fn, formats_fn, opts) ⇒ Parser
Returns a new instance of Parser.
17 18 19 20 21 22 |
# File 'lib/kaitai/struct/visualizer/parser.rb', line 17 def initialize(compiler, bin_fn, formats_fn, opts) @compiler = compiler @bin_fn = bin_fn @formats_fn = formats_fn @opts = opts end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
15 16 17 |
# File 'lib/kaitai/struct/visualizer/parser.rb', line 15 def data @data end |
Instance Method Details
#load ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/kaitai/struct/visualizer/parser.rb', line 24 def load main_class_name = @compiler.compile_formats(@formats_fn) main_class = Kernel::const_get(main_class_name) @data = main_class.from_file(@bin_fn) load_exc = nil begin @data._read rescue EOFError => e load_exc = e rescue Kaitai::Struct::Stream::UnexpectedDataError => e load_exc = e end return load_exc end |