Class: MrbParser::Section
- Inherits:
-
Object
- Object
- MrbParser::Section
- Defined in:
- lib/mrb_parser/section.rb
Direct Known Subclasses
Constant Summary collapse
- BINARY_EOF =
"END\0"
- IREP_IDENTIFIER =
"IREP"
- LINENO_IDENTIFIER =
"LINE"
- DEBUG_IDENTIFIER =
"DBG\0"
Instance Attribute Summary collapse
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
- #end? ⇒ Boolean
-
#initialize(signature = nil, size = nil) ⇒ Section
constructor
A new instance of Section.
- #parse(parser) ⇒ Object
Constructor Details
#initialize(signature = nil, size = nil) ⇒ Section
Returns a new instance of Section.
16 17 18 19 |
# File 'lib/mrb_parser/section.rb', line 16 def initialize(signature = nil, size = nil) @signature = signature @size = size end |
Instance Attribute Details
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
14 15 16 |
# File 'lib/mrb_parser/section.rb', line 14 def signature @signature end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
14 15 16 |
# File 'lib/mrb_parser/section.rb', line 14 def size @size end |
Class Method Details
Instance Method Details
#end? ⇒ Boolean
46 47 48 |
# File 'lib/mrb_parser/section.rb', line 46 def end? false end |
#parse(parser) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mrb_parser/section.rb', line 26 def parse(parser) signature = parser.read_chars(4) size = parser.read_uint32 case signature when IREP_IDENTIFIER section = MrbParser::IrepSection when LINENO_IDENTIFIER section = MrbParser::LinenoSection when DEBUG_IDENTIFIER section = MrbParser::DebugSection when BINARY_EOF section = MrbParser::EndSection else raise MrbParser::Error, "cannot parse; invalid section signature: '#{signature}'" end sec = section.new(signature, size) sec.parse_body(parser) sec end |