Class: Resilience::FSDir::Record
- Inherits:
-
Object
- Object
- Resilience::FSDir::Record
show all
- Includes:
- OnImage
- Defined in:
- lib/resilience/fs_dir/record.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from OnImage
#image, image, included, restore_pos, #restore_pos, store_pos, #store_pos
Constructor Details
#initialize(attribute) ⇒ Record
Returns a new instance of Record.
12
13
14
|
# File 'lib/resilience/fs_dir/record.rb', line 12
def initialize(attribute)
@attribute = attribute
end
|
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
10
11
12
|
# File 'lib/resilience/fs_dir/record.rb', line 10
def attribute
@attribute
end
|
Class Method Details
.read ⇒ Object
16
17
18
|
# File 'lib/resilience/fs_dir/record.rb', line 16
def self.read
new(Attribute.read)
end
|
Instance Method Details
#boundries ⇒ Object
31
32
33
34
|
# File 'lib/resilience/fs_dir/record.rb', line 31
def boundries
calc_boundries
[@key_offset, @key_length, @value_offset, @value_length]
end
|
#calc_boundries ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/resilience/fs_dir/record.rb', line 20
def calc_boundries
return if @boundries_set
@boundries_set = true
= attribute.unpack('S*')
@key_offset = [2]
@key_length = [3]
@value_offset = [5]
@value_length = [6]
end
|
#calc_flags ⇒ Object
36
37
38
39
40
41
|
# File 'lib/resilience/fs_dir/record.rb', line 36
def calc_flags
return if @flags_set
@flags_set = true
@flags = attribute.unpack('S*')[4]
end
|
#flags ⇒ Object
43
44
45
46
|
# File 'lib/resilience/fs_dir/record.rb', line 43
def flags
calc_flags
@flags
end
|
#key ⇒ Object
48
49
50
51
|
# File 'lib/resilience/fs_dir/record.rb', line 48
def key
ko, kl, vo, vl = boundries
attribute.unpack('C*')[ko...ko+kl].pack('C*')
end
|
#value ⇒ Object
53
54
55
56
|
# File 'lib/resilience/fs_dir/record.rb', line 53
def value
ko, kl, vo, vl = boundries
attribute.unpack('C*')[vo..-1].pack('C*')
end
|