Class: RBZK::Finger

Inherits:
Object
  • Object
show all
Defined in:
lib/rbzk/finger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uid, fid, valid, template = '') ⇒ Finger

Returns a new instance of Finger.



7
8
9
10
11
12
13
# File 'lib/rbzk/finger.rb', line 7

def initialize(uid, fid, valid, template = '')
  @uid = uid
  @fid = fid
  @valid = valid
  @template = template
  @size = template.length
end

Instance Attribute Details

#fidObject

Returns the value of attribute fid.



5
6
7
# File 'lib/rbzk/finger.rb', line 5

def fid
  @fid
end

#sizeObject

Returns the value of attribute size.



5
6
7
# File 'lib/rbzk/finger.rb', line 5

def size
  @size
end

#templateObject

Returns the value of attribute template.



5
6
7
# File 'lib/rbzk/finger.rb', line 5

def template
  @template
end

#uidObject

Returns the value of attribute uid.



5
6
7
# File 'lib/rbzk/finger.rb', line 5

def uid
  @uid
end

#validObject

Returns the value of attribute valid.



5
6
7
# File 'lib/rbzk/finger.rb', line 5

def valid
  @valid
end

Instance Method Details

#repackObject

Pack the finger data into a binary string (full data)



16
17
18
# File 'lib/rbzk/finger.rb', line 16

def repack
  [@size + 6, @uid, @fid, @valid].pack('S<S<CC') + @template
end

#repack_onlyObject

Pack only the template data into a binary string



21
22
23
# File 'lib/rbzk/finger.rb', line 21

def repack_only
  [@size].pack('S<') + @template
end

#to_sObject



25
26
27
# File 'lib/rbzk/finger.rb', line 25

def to_s
  "#{@uid} #{@fid} #{@valid} #{@template.length}"
end