Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/number.rb

Instance Method Summary collapse

Instance Method Details

#millisObject



16
17
18
# File 'lib/core_ext/number.rb', line 16

def millis
  self / 1_000.0
end

#to_bytes_aryObject



10
11
12
13
14
# File 'lib/core_ext/number.rb', line 10

def to_bytes_ary
  res = []
  to_hex_str.chars.each_slice(2) { |byte| res << byte.join().to_i(16) }
  res
end

#to_hex_strObject



2
3
4
5
6
7
8
# File 'lib/core_ext/number.rb', line 2

def to_hex_str
  n = to_s(16).upcase
  if n.length.odd?
    n = "0#{n}"
  end
  n
end