Class: Flare::Tools::Cli::Restore::TchRestorer
- Defined in:
- lib/flare/tools/cli/restore.rb
Instance Attribute Summary
Attributes inherited from Restorer
Class Method Summary collapse
-
.myname ⇒ Object
uint32_t flag -> L // uint32_t time_t expire -> Q // unsigned long uint64_t size -> Q // uint64_t uint64_t version -> Q // uint64_t uint32_t option -> L // uint32_t.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(filepath) ⇒ TchRestorer
constructor
A new instance of TchRestorer.
- #iterate(&block) ⇒ Object
Constructor Details
#initialize(filepath) ⇒ TchRestorer
Returns a new instance of TchRestorer.
45 46 47 48 49 50 |
# File 'lib/flare/tools/cli/restore.rb', line 45 def initialize filepath raise "output file not specified." if filepath.nil? raise "#{filepath} isn't a path." unless filepath.kind_of?(String) @hdb = TokyoCabinet::HDB.new @hdb.open(filepath, TokyoCabinet::HDB::OCREAT|TokyoCabinet::HDB::OREADER) end |
Class Method Details
.myname ⇒ Object
uint32_t flag -> L // uint32_t time_t expire -> Q // unsigned long uint64_t size -> Q // uint64_t uint64_t version -> Q // uint64_t uint32_t option -> L // uint32_t
42 43 44 |
# File 'lib/flare/tools/cli/restore.rb', line 42 def self.myname "tch" end |
Instance Method Details
#close ⇒ Object
61 62 63 |
# File 'lib/flare/tools/cli/restore.rb', line 61 def close @hdb.close end |
#iterate(&block) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/flare/tools/cli/restore.rb', line 51 def iterate &block @hdb.iterinit while (key = @hdb.iternext) value = @hdb.get(key) a = value.unpack("LQQQC*") flag, expire, size, version = a.shift(4) data = a.pack("C*") block.call(key, data, flag, expire) end end |