Class: SDBTools::DumpFile
- Inherits:
-
Object
- Object
- SDBTools::DumpFile
- Includes:
- Enumerable
- Defined in:
- lib/sdbtools.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(path) ⇒ DumpFile
constructor
A new instance of DumpFile.
- #item_names ⇒ Object
- #size ⇒ Object
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
#each ⇒ Object
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_names ⇒ Object
206 207 208 |
# File 'lib/sdbtools.rb', line 206 def item_names map{|item_name, item| item_name} end |
#size ⇒ Object
210 211 212 213 214 |
# File 'lib/sdbtools.rb', line 210 def size inject(0){|size, item_name, item| size += 1 } end |