Sha256: 6c5d7070842438118ece9e18e49b32fb380d79c95f525ba2a46dc20224afaff6
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
module OneWire class Directory include Retry # include Enumerable def initialize(path, options = {}) @path = path dirall = options.has_key?(:dir_all) ? options[:dirall] : Config.dirall @entries = dirall ? with_retry { Transaction.dirall(path) }.response.data.split(",") : with_retry { Transaction.dir(path) }.response.map { |r| r.data } end def directories @directories ||= @entries.collect do |entry| begin Directory.new(entry) rescue Errno::ENOTDIR nil end end.compact end def members @members ||= @entries - directories.map { |directory| directory.path } end attr_reader :path def ls [ "+ " + @path.split("/").last.to_s ] + members.map { |member| " . " + member.split("/").last } + directories.map { |directory| " - " + directory.path.split("/").last } end def tree [ "+ " + @path.split("/").last.to_s ] + members.map { |member| " . " + member.split("/").last } + directories.map { |directory| directory.tree.map { |line| " #{line}"} }.flatten end def to_s ls.join("\n") end def inspect to_s end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
mholling-one_wire-0.1.0 | lib/one_wire/directory.rb |
one_wire-0.1.1 | lib/one_wire/directory.rb |
one_wire-0.1.0 | lib/one_wire/directory.rb |