Class: JavaClass::ClassFile::ClassMagic
- Inherits:
-
Object
- Object
- JavaClass::ClassFile::ClassMagic
- Defined in:
- lib/javaclass/classfile/class_magic.rb
Overview
The CAFEBABE
magic of a class file. This just checks if CAFEBABE is here.
- Author
-
Peter Kofler
Constant Summary collapse
- CAFE_BABE =
ZenTest SKIP
"\xCA\xFE\xBA\xBE"
Instance Method Summary collapse
-
#bytes ⇒ Object
Return the value of the magic in this class.
-
#initialize(data, start = 0) ⇒ ClassMagic
constructor
Check the class magic in the data beginning at position start (which is usually 0).
-
#valid? ⇒ Boolean
Return
true
if the data was valid, i.e.
Constructor Details
#initialize(data, start = 0) ⇒ ClassMagic
Check the class magic in the data beginning at position start (which is usually 0).
11 12 13 14 |
# File 'lib/javaclass/classfile/class_magic.rb', line 11 def initialize(data, start=0) # "parsing" @bytes = data[start..start+3] end |
Instance Method Details
#bytes ⇒ Object
Return the value of the magic in this class.
22 23 24 |
# File 'lib/javaclass/classfile/class_magic.rb', line 22 def bytes @bytes.dup end |
#valid? ⇒ Boolean
Return true
if the data was valid, i.e. if the class started with CAFEBABE
.
17 18 19 |
# File 'lib/javaclass/classfile/class_magic.rb', line 17 def valid? @bytes == CAFE_BABE end |