Class: Microsandbox::FsEntry
- Inherits:
-
Object
- Object
- Microsandbox::FsEntry
- Defined in:
- lib/microsandbox/fs.rb
Overview
A directory entry returned by Microsandbox::FS#list.
Instance Attribute Summary collapse
-
#mode ⇒ Integer
readonly
POSIX mode bits.
-
#path ⇒ String
readonly
Absolute guest path.
-
#size ⇒ Integer
readonly
Size in bytes.
-
#type ⇒ Symbol
readonly
One of :file, :directory, :symlink, :other.
Instance Method Summary collapse
- #directory? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(data) ⇒ FsEntry
constructor
A new instance of FsEntry.
- #inspect ⇒ Object
-
#modified ⇒ Time?
Last-modified time, if known.
-
#name ⇒ String
The final path component.
- #symlink? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ FsEntry
Returns a new instance of FsEntry.
15 16 17 18 19 20 21 |
# File 'lib/microsandbox/fs.rb', line 15 def initialize(data) @path = data["path"] @type = data["type"].to_sym @size = data["size"] @mode = data["mode"] @modified_ms = data["modified_ms"] end |
Instance Attribute Details
#mode ⇒ Integer (readonly)
Returns POSIX mode bits.
13 14 15 |
# File 'lib/microsandbox/fs.rb', line 13 def mode @mode end |
#path ⇒ String (readonly)
Returns absolute guest path.
7 8 9 |
# File 'lib/microsandbox/fs.rb', line 7 def path @path end |
#size ⇒ Integer (readonly)
Returns size in bytes.
11 12 13 |
# File 'lib/microsandbox/fs.rb', line 11 def size @size end |
#type ⇒ Symbol (readonly)
Returns one of :file, :directory, :symlink, :other.
9 10 11 |
# File 'lib/microsandbox/fs.rb', line 9 def type @type end |
Instance Method Details
#directory? ⇒ Boolean
34 |
# File 'lib/microsandbox/fs.rb', line 34 def directory? = @type == :directory |
#file? ⇒ Boolean
33 |
# File 'lib/microsandbox/fs.rb', line 33 def file? = @type == :file |
#inspect ⇒ Object
37 38 39 |
# File 'lib/microsandbox/fs.rb', line 37 def inspect "#<Microsandbox::FsEntry path=#{@path.inspect} type=#{@type} size=#{@size}>" end |
#modified ⇒ Time?
Returns last-modified time, if known.
29 30 31 |
# File 'lib/microsandbox/fs.rb', line 29 def modified @modified_ms && Time.at(@modified_ms / 1000.0) end |
#name ⇒ String
Returns the final path component.
24 25 26 |
# File 'lib/microsandbox/fs.rb', line 24 def name File.basename(@path) end |
#symlink? ⇒ Boolean
35 |
# File 'lib/microsandbox/fs.rb', line 35 def symlink? = @type == :symlink |