Module: FWTAdapter
- Includes:
- TSVAdapter
- Defined in:
- lib/scout/persist/tsv/adapter/fix_width_table.rb
Constant Summary
Constants included
from TSVAdapter
TSVAdapter::ANNOTATION_ATTR_HASH_KEY, TSVAdapter::ANNOTATION_ATTR_HASH_SERIALIZER, TSVAdapter::MAX_CHAR, TSVAdapter::SERIALIZER_ALIAS
Instance Attribute Summary collapse
Attributes included from TSVAdapter
#closed, #persistence_class, #persistence_path, #serializer, #writable
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from TSVAdapter
#close, #closed?, #collect, #delete, #each_annotation_hash_key, #get_prefix, #keys_annotation_hash_key, #load_value, #lock, #lock_and_close, #merge!, #orig_get, #orig_set, #prefix, #range, #read, #read?, #read_and_close, #read_lock, #save_value, serializer_module, #size_annotation_hash_key, #values, #values_at, #with_read, #with_write, #write, #write?, #write_and_close, #write_and_read, #write_lock
Instance Attribute Details
#pos_function ⇒ Object
Returns the value of attribute pos_function.
12
13
14
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 12
def pos_function
@pos_function
end
|
Class Method Details
.extended(base) ⇒ Object
7
8
9
10
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 7
def self.extended(base)
base.extend TSVAdapter
base
end
|
Instance Method Details
#[](key, clean = false) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 43
def [](key, clean = false)
key = pos_function.call(key) if pos_function and not clean
res = super(key)
return nil if res.nil?
res = res.collect{|r| load_value(r) }
res.extend MultipleResult
res
end
|
#[]=(key, value) ⇒ Object
52
53
54
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 52
def []=(key, value)
self.add(key, value)
end
|
#add(key, value) ⇒ Object
31
32
33
34
35
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 31
def add(key, value)
key = pos_function.call(key) if pos_function and not (@range and Array === key)
value = save_value(value)
super(key, value)
end
|
#add_range_point(key, value) ⇒ Object
37
38
39
40
41
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 37
def add_range_point(key, value)
key = pos_function.call(key) if pos_function
value = save_value(value)
super(key, value)
end
|
#each ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 66
def each
read
@size.times do |i|
v = idx_value(i)
yield i, v
end
end
|
#include?(i) ⇒ Boolean
56
57
58
59
60
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 56
def include?(i)
return true if Numeric === i and i < pos(@size)
@annotations
false
end
|
#keys ⇒ Object
74
75
76
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 74
def keys
[]
end
|
#load_annotation_hash ⇒ Object
23
24
25
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 23
def load_annotation_hash
ANNOTATION_ATTR_HASH_SERIALIZER.load(Open.read(metadata_file, mode: 'b'))
end
|
19
20
21
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 19
def metadata_file
@metadata_file ||= self.persistence_path + '.metadata'
end
|
#persistence_path=(value) ⇒ Object
14
15
16
17
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 14
def persistence_path=(value)
@persistence_path = value
@filename = value
end
|
#save_annotation_hash ⇒ Object
27
28
29
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 27
def save_annotation_hash
Open.write(metadata_file, ANNOTATION_ATTR_HASH_SERIALIZER.dump(self.annotation_hash), mode: 'wb')
end
|
#size ⇒ Object
62
63
64
|
# File 'lib/scout/persist/tsv/adapter/fix_width_table.rb', line 62
def size
@size
end
|