Class: MemoryIO::Util::FilePermission
- Inherits:
-
Object
- Object
- MemoryIO::Util::FilePermission
- Defined in:
- lib/memory_io/util.rb
Overview
A simple class to be returned for getting file permissions.
Instance Attribute Summary collapse
-
#readable ⇒ Object
(also: #readable?)
readonly
Returns the value of attribute readable.
-
#writable ⇒ Object
(also: #writable?)
readonly
Returns the value of attribute writable.
Instance Method Summary collapse
-
#initialize(file) ⇒ FilePermission
constructor
A new instance of FilePermission.
Constructor Details
#initialize(file) ⇒ FilePermission
Returns a new instance of FilePermission.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/memory_io/util.rb', line 15 def initialize(file) stat = File.stat(file) @readable = stat.readable_real? @writable = stat.writable_real? # we do a trick here because /proc/[pid]/mem might be marked as writeable but fails at sysopen. begin @readable && File.open(file, 'rb').close rescue Errno::EACCES @readable = false end begin @writable && File.open(file, 'wb').close rescue Errno::EACCES @writable = false end end |
Instance Attribute Details
#readable ⇒ Object (readonly) Also known as: readable?
Returns the value of attribute readable.
10 11 12 |
# File 'lib/memory_io/util.rb', line 10 def readable @readable end |
#writable ⇒ Object (readonly) Also known as: writable?
Returns the value of attribute writable.
10 11 12 |
# File 'lib/memory_io/util.rb', line 10 def writable @writable end |