Class: JavaClass::Constants::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/javaclass/constants/base.rb

Overview

Superclass of constant values in the constant pool. Every constant has a name, a tag and a size in bytes.

Author

Peter Kofler

Direct Known Subclasses

SingleReference, Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Base

Set default constants.



16
17
18
19
20
21
# File 'lib/javaclass/constants/base.rb', line 16

def initialize(name=nil)
  @name = self.class.to_s[/::[^:]+$/][10..-1] # skip modules (::) and "Constant"
  @name = name if name
  @size = 3
  @slots = 1
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/javaclass/constants/base.rb', line 10

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



12
13
14
# File 'lib/javaclass/constants/base.rb', line 12

def size
  @size
end

#slotsObject (readonly)

Returns the value of attribute slots.



13
14
15
# File 'lib/javaclass/constants/base.rb', line 13

def slots
  @slots
end

#tagObject (readonly)

Returns the value of attribute tag.



11
12
13
# File 'lib/javaclass/constants/base.rb', line 11

def tag
  @tag
end

Instance Method Details

#dumpObject

Return part of debug output.



24
25
26
# File 'lib/javaclass/constants/base.rb', line 24

def dump
  "#{@name}\t" # #{@tag} 
end