Class: TrisulRP::Keys::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/trisulrp/keys.rb

Class Method Summary collapse

Class Method Details

.invert_xform(dstring) {|ret| ... } ⇒ Object

human string to key

Yields:

  • (ret)


54
55
56
57
58
# File 'lib/trisulrp/keys.rb', line 54

def self.invert_xform(dstring)
  ret = dstring.split('.').collect { |decbyte| decbyte.to_i.to_s(16).rjust(2,"00").upcase}.join('.')
  yield ret if block_given?
  ret
end

.is_human_form?(patt) ⇒ Boolean

is_human_pattern?

Returns:

  • (Boolean)


67
68
69
# File 'lib/trisulrp/keys.rb', line 67

def self.is_human_form? patt
  patt.split('.').select { |szbyte| (1..255).cover?(szbyte.to_i) or szbyte.squeeze("0") == "0" }.size == 4
end

.is_key_form?(patt) ⇒ Boolean

is_key_pattern?

Returns:

  • (Boolean)


61
62
63
64
# File 'lib/trisulrp/keys.rb', line 61

def self.is_key_form? patt
  return false if patt.nil?
  patt.length == 11 and (patt[2] == "." || patt[5] == "." || patt[8] == ".")
end

.xform(kstring) {|ret| ... } ⇒ Object

key to human string

Yields:

  • (ret)


47
48
49
50
51
# File 'lib/trisulrp/keys.rb', line 47

def self.xform(kstring)
  ret = kstring.split('.').collect { |hexbyte| hexbyte.hex.to_s }.join('.')
  yield ret if block_given?
  ret
end