Class: SDBTools::DumpFile

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sdbtools.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ DumpFile

Returns a new instance of DumpFile.



202
203
204
# File 'lib/sdbtools.rb', line 202

def initialize(path)
  @path = Pathname(path)
end

Instance Method Details

#eachObject



216
217
218
219
220
221
222
# File 'lib/sdbtools.rb', line 216

def each
  @path.open('r') {|f|
    YAML.load_documents(f) {|doc|
      yield doc.keys.first, doc.values.first
    }
  }
end

#item_namesObject



206
207
208
# File 'lib/sdbtools.rb', line 206

def item_names
  map{|item_name, item| item_name}
end

#sizeObject



210
211
212
213
214
# File 'lib/sdbtools.rb', line 210

def size
  inject(0){|size, item_name, item|
    size += 1
  }
end