Class: ExternalArray

Inherits:
ExternalArchive show all
Defined in:
lib/external_array.rb

Overview

– YAML cannot/does not properly handle:

  • Proc

  • Class (cannot dump)

  • Carriage return strings (removes “r”): “r”, “rn”, “string_with_rn_internal”

  • Chains of newlines (loads to “”): “n”, “nn”

Bugs:

@cls[ 'cat', 99, /a/, @cls[ 1, 2, 3] ].include?(@cls[ 1, 2, 3])  raises error

++

Constant Summary

Constants inherited from External::Base

External::Base::TEMPFILE_BASENAME

Instance Attribute Summary

Attributes inherited from ExternalArchive

#io_index

Attributes inherited from External::Base

#io

Attributes included from External::Chunkable

#default_blksize, #length

Attributes included from External::Enumerable

#enumerate_to_a

Instance Method Summary collapse

Methods inherited from ExternalArchive

#+, #<<, #<=>, #==, #[], [], #[]=, #another, #at, #cache=, #cached?, #clear, #close, #compact, #concat, #each, #each_str, #eachio_index, index_path, #initialize, #last, #length, open, #push, #reindex_by_regexp, #reindex_by_sep, #reset_index, #reverse_each, #reverse_each_str, #size, #to_a, #values_at

Methods inherited from External::Base

#another, #close, #closed?, #dup, #empty?, #eql?, #first, #flush, #initialize, #inspect, open, #slice, #to_ary

Methods included from External::Chunkable

#chunk, #default_span, range_begin_and_end, #reverse_chunk, split_range, split_span

Methods included from External::Enumerable

#all?, #any?, #collect, #detect, #each_with_index, #entries, #find, #find_all, #include?, #map, #member?, #select

Constructor Details

This class inherits a constructor from ExternalArchive

Instance Method Details

#entry_to_str(entry) ⇒ Object



52
53
54
# File 'lib/external_array.rb', line 52

def entry_to_str(entry)
  entry.to_yaml
end

#reindex(&block) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/external_array.rb', line 40

def reindex(&block)
  reindex_by_sep(nil, 
    :sep_regexp => /^-{3} /, 
    :sep_length => 4, 
    :entry_follows_sep => true,
    &block)
end

#str_to_entry(str) ⇒ Object



48
49
50
# File 'lib/external_array.rb', line 48

def str_to_entry(str)
  str == nil || str.empty? ? nil : YAML.load(str)
end