Class: DatxRuby::Util
- Inherits:
-
Object
- Object
- DatxRuby::Util
- Defined in:
- lib/datx_ruby/util.rb
Overview
工具
Class Method Summary collapse
- .bytes2long(four, three, two, one) ⇒ Object
- .check_code(content, num) ⇒ Object
- .ip2long(ip) ⇒ Object
Class Method Details
.bytes2long(four, three, two, one) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/datx_ruby/util.rb', line 12 def bytes2long(four, three, two, one) four = check_code(four, 24) three = check_code(three, 16) two = check_code(two, 8) one = check_code(one, 0) four | three | two | one end |
.check_code(content, num) ⇒ Object
20 21 22 |
# File 'lib/datx_ruby/util.rb', line 20 def check_code(content, num) content.unpack("C*")[0] << num end |
.ip2long(ip) ⇒ Object
8 9 10 |
# File 'lib/datx_ruby/util.rb', line 8 def ip2long(ip) ::IPAddr.new(ip).to_i end |