Module: JavaClass::Base
- Included in:
- AccessFlag, Annotation, AnnotationElement, AnnotationElementValue, Attribute, Class, Code, Constant, Excpetion, InnerClass, LineNumber, LocalVariable, LocalVariableType, Member, ObjectVariableInfo, Operand, StackMapFrame, UninitializedVariableInfo, VariableInfo
- Defined in:
- lib/javaclass/base.rb
Instance Method Summary collapse
-
#==(other) ⇒ Object
オブジェクト比較メソッド.
- #===(other) ⇒ Object
-
#dump ⇒ Object
16進数表現の文字列形式に変換する.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#to_byte(value, length, signed = false) ⇒ Object
0..255の数字の配列に変換する.
Instance Method Details
#==(other) ⇒ Object
オブジェクト比較メソッド
59 60 61 |
# File 'lib/javaclass/base.rb', line 59 def ==(other) _eql?(other) { |a,b| a == b } end |
#===(other) ⇒ Object
62 63 64 |
# File 'lib/javaclass/base.rb', line 62 def ===(other) _eql?(other) { |a,b| a === b } end |
#dump ⇒ Object
16進数表現の文字列形式に変換する
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/javaclass/base.rb', line 47 def dump() buff = "" i = 1 self.to_bytes().each {|b| buff << sprintf("%0.2X", b) buff << (i%16==0 ? "\n" : i%4==0 ? " " : "") i+=1 } return buff.strip end |
#eql?(other) ⇒ Boolean
65 66 67 |
# File 'lib/javaclass/base.rb', line 65 def eql?(other) _eql?(other) { |a,b| a.eql? b } end |
#hash ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/javaclass/base.rb', line 68 def hash hash = 0 values.each {|v| hash = v.hash + 31 * hash } return hash end |
#to_byte(value, length, signed = false) ⇒ Object
0..255の数字の配列に変換する
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/javaclass/base.rb', line 30 def to_byte( value, length, signed=false ) return [0x00]*length if value == nil if signed && value < 0 border = 0x80 << (8 * (length-1)) value = (value + border) | border end tmp = [] length.times {|i| tmp.unshift( value & 0xFF ) value >>= 8 } return tmp end |