Class: Microsandbox::FsMetadata
- Inherits:
-
Object
- Object
- Microsandbox::FsMetadata
- Defined in:
- lib/microsandbox/fs.rb
Overview
File/directory metadata returned by Microsandbox::FS#stat.
Instance Attribute Summary collapse
-
#mode ⇒ Integer
readonly
POSIX mode bits.
-
#size ⇒ Integer
readonly
Size in bytes.
-
#type ⇒ Symbol
readonly
One of :file, :directory, :symlink, :other.
Instance Method Summary collapse
-
#created ⇒ Time?
Creation time, if known.
- #directory? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(data) ⇒ FsMetadata
constructor
A new instance of FsMetadata.
- #inspect ⇒ Object
-
#modified ⇒ Time?
Last-modified time, if known.
- #readonly? ⇒ Boolean
- #symlink? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ FsMetadata
Returns a new instance of FsMetadata.
51 52 53 54 55 56 57 58 |
# File 'lib/microsandbox/fs.rb', line 51 def initialize(data) @type = data["type"].to_sym @size = data["size"] @mode = data["mode"] @readonly = data["readonly"] @modified_ms = data["modified_ms"] @created_ms = data["created_ms"] end |
Instance Attribute Details
#mode ⇒ Integer (readonly)
Returns POSIX mode bits.
49 50 51 |
# File 'lib/microsandbox/fs.rb', line 49 def mode @mode end |
#size ⇒ Integer (readonly)
Returns size in bytes.
47 48 49 |
# File 'lib/microsandbox/fs.rb', line 47 def size @size end |
#type ⇒ Symbol (readonly)
Returns one of :file, :directory, :symlink, :other.
45 46 47 |
# File 'lib/microsandbox/fs.rb', line 45 def type @type end |
Instance Method Details
#created ⇒ Time?
Returns creation time, if known.
71 72 73 |
# File 'lib/microsandbox/fs.rb', line 71 def created @created_ms && Time.at(@created_ms / 1000.0) end |
#directory? ⇒ Boolean
62 |
# File 'lib/microsandbox/fs.rb', line 62 def directory? = @type == :directory |
#file? ⇒ Boolean
61 |
# File 'lib/microsandbox/fs.rb', line 61 def file? = @type == :file |
#inspect ⇒ Object
75 76 77 |
# File 'lib/microsandbox/fs.rb', line 75 def inspect "#<Microsandbox::FsMetadata type=#{@type} size=#{@size} mode=#{format("%o", @mode)}>" end |
#modified ⇒ Time?
Returns last-modified time, if known.
66 67 68 |
# File 'lib/microsandbox/fs.rb', line 66 def modified @modified_ms && Time.at(@modified_ms / 1000.0) end |
#readonly? ⇒ Boolean
60 |
# File 'lib/microsandbox/fs.rb', line 60 def readonly? = @readonly |
#symlink? ⇒ Boolean
63 |
# File 'lib/microsandbox/fs.rb', line 63 def symlink? = @type == :symlink |