Module: EPM::HexData
Instance Method Summary collapse
- #construct_data(deconstructed_data) ⇒ Object
- #hex_guard(data) ⇒ Object
- #query_guard(position) ⇒ Object
Instance Method Details
#construct_data(deconstructed_data) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/epm/utils.rb', line 133 def construct_data deconstructed_data data = "0x" deconstructed_data.each do |bits| if bits[0..1] == "0x" piece = bits[2..-1] piece = piece.rjust(64,'0') else piece = bits.unpack('c*').map{|s| s.to_s(16)}.join('') piece = piece.ljust(64,'0') if piece == "2727000000000000000000000000000000000000000000000000000000000000" || piece == "2222000000000000000000000000000000000000000000000000000000000000" piece = "0000000000000000000000000000000000000000000000000000000000000000" end end data << piece end return data end |
#hex_guard(data) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/epm/utils.rb', line 119 def hex_guard data if data[0..1] != "0x" data = "0x" + data end return data end |
#query_guard(position) ⇒ Object
126 127 128 129 130 131 |
# File 'lib/epm/utils.rb', line 126 def query_guard position if position[0..1] != '0x' position = construct_data( [ position ] ) end return position end |