Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/struct_ex/struct_ex.rb

Instance Method Summary collapse

Instance Method Details

#to_decObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/ffi/struct_ex/struct_ex.rb', line 10

def to_dec
  case self
    when /^[+-]?\d+$/
      self.to_i
    when /^[+-]?0[xX][\da-fA-F_]+$/
      self.to_i(16)
    when /^[+-]?0[bB][_01]+$/
      self.to_i(2)
  end
end