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



19
20
21
22
23
24
25
26
27
28
# File 'lib/ffi/struct_ex/struct_ex.rb', line 19

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