class Zashoku::Net::ClientSan

Constants

KANA

Attributes

c[R]

Public Class Methods

new(client) click to toggle source
# File lib/core/net/client_san.rb, line 16
def initialize(client)
  @c = client
end

Public Instance Methods

generate_name(hash) click to toggle source
# File lib/core/net/client_san.rb, line 24
def generate_name(hash)
  coll = ''
  hash.abs.to_s[0..5].chars.map do |c|
    coll += c
    if coll.to_i >= KANA.length
      KANA[coll.to_i % KANA.length]
    end
  end.compact.join + '-san'
end
to_s() click to toggle source
# File lib/core/net/client_san.rb, line 20
def to_s
  "#{@name || @name = generate_name(@c.hash)}@#{@c.addr[2]}:#{@c.addr[1]}"
end