Class: Zold::Wallets
- Inherits:
-
Object
- Object
- Zold::Wallets
- Defined in:
- lib/zold/wallets.rb
Overview
Collection of local wallets
Instance Method Summary collapse
-
#all ⇒ Object
Returns the list of their IDs (as plain text).
- #find(id) ⇒ Object
-
#initialize(dir) ⇒ Wallets
constructor
A new instance of Wallets.
- #path ⇒ Object
Constructor Details
#initialize(dir) ⇒ Wallets
Returns a new instance of Wallets.
31 32 33 |
# File 'lib/zold/wallets.rb', line 31 def initialize(dir) @dir = dir end |
Instance Method Details
#all ⇒ Object
Returns the list of their IDs (as plain text)
41 42 43 44 45 46 47 48 49 |
# File 'lib/zold/wallets.rb', line 41 def all Dir.new(path).select do |f| file = File.join(@dir, f) File.file?(file) && !File.directory?(file) && f =~ /[0-9a-fA-F]{16}/ && Id.new(f).to_s == f end end |
#find(id) ⇒ Object
51 52 53 |
# File 'lib/zold/wallets.rb', line 51 def find(id) Zold::Wallet.new(File.join(path, id.to_s)) end |
#path ⇒ Object
35 36 37 38 |
# File 'lib/zold/wallets.rb', line 35 def path FileUtils.mkdir_p(@dir) File.(@dir) end |