Class: JvmBytecode::Constants::Class

Inherits:
Constant
  • Object
show all
Defined in:
lib/jvm_bytecode/constants/class.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Constant

#bytecode, define, fetch

Constructor Details

#initialize(name_index) ⇒ Class



12
13
14
# File 'lib/jvm_bytecode/constants/class.rb', line 12

def initialize(name_index)
  @name_index = name_index
end

Instance Attribute Details

#name_indexObject (readonly)

Returns the value of attribute name_index.



6
7
8
# File 'lib/jvm_bytecode/constants/class.rb', line 6

def name_index
  @name_index
end

Class Method Details

.decode(io) ⇒ Object



8
9
10
# File 'lib/jvm_bytecode/constants/class.rb', line 8

def self.decode(io)
  new(io.read(2).unpack('S>').first)
end

Instance Method Details

#additional_bytecodeObject



16
17
18
# File 'lib/jvm_bytecode/constants/class.rb', line 16

def additional_bytecode
  [@name_index].pack('S>')
end

#to_hashObject



20
21
22
# File 'lib/jvm_bytecode/constants/class.rb', line 20

def to_hash
  { name_index: @name_index }
end