Class: Zashoku::Net::ClientSan
- Inherits:
-
Object
- Object
- Zashoku::Net::ClientSan
- Defined in:
- lib/core/net/client_san.rb
Constant Summary collapse
- KANA =
[ 'a', 'i', 'u', 'e', 'o', 'ka', 'ki', 'ku', 'ke', 'ko', 'sa', 'shi', 'su', 'se', 'so', 'ta', 'chi', 'tsu', 'te', 'to', 'na', 'ni', 'nu', 'ne', 'no', 'ha', 'hi', 'fu', 'he', 'ho', 'ma', 'mi', 'mu', 'me', 'mo', 'ya', 'yu','yo', 'ra', 'ri', 'ru', 're', 'ro', 'wa', 'n' ]
Instance Attribute Summary collapse
-
#c ⇒ Object
readonly
Returns the value of attribute c.
Instance Method Summary collapse
- #generate_name(hash) ⇒ Object
-
#initialize(client) ⇒ ClientSan
constructor
A new instance of ClientSan.
- #to_s ⇒ Object
Constructor Details
#initialize(client) ⇒ ClientSan
16 17 18 |
# File 'lib/core/net/client_san.rb', line 16 def initialize(client) @c = client end |
Instance Attribute Details
#c ⇒ Object (readonly)
Returns the value of attribute c.
14 15 16 |
# File 'lib/core/net/client_san.rb', line 14 def c @c end |
Instance Method Details
#generate_name(hash) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
20 21 22 |
# 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 |