Class: SugarUtils::File::WriteOptions Private
- Inherits:
-
Object
- Object
- SugarUtils::File::WriteOptions
- Defined in:
- lib/sugar_utils/file/write_options.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #flush? ⇒ Boolean private
- #group ⇒ String, Intekuuger private
-
#initialize(filename, options) ⇒ WriteOptions
constructor
private
A new instance of WriteOptions.
- #owner ⇒ String, Integer private
- #perm(default_value = 0o644) ⇒ Integer private
- #slice(*args) ⇒ Hash private
Constructor Details
#initialize(filename, options) ⇒ WriteOptions
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of WriteOptions.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sugar_utils/file/write_options.rb', line 9 def initialize(filename, ) @filename = filename @options = return unless filename && ::File.exist?(filename) file_stat = ::File::Stat.new(filename) @existing_owner = file_stat.uid @existing_group = file_stat.gid end |
Instance Method Details
#flush? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/sugar_utils/file/write_options.rb', line 21 def flush? @options[:flush] || false end |
#group ⇒ String, Intekuuger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'lib/sugar_utils/file/write_options.rb', line 44 def group @options[:group] || @existing_group end |
#owner ⇒ String, Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/sugar_utils/file/write_options.rb', line 39 def owner @options[:owner] || @existing_owner end |
#perm ⇒ Integer #perm(default_value) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 |
# File 'lib/sugar_utils/file/write_options.rb', line 32 def perm(default_value = 0o644) # NOTE: We are using the variable name 'perm' because that is the name # of the argument used by File.open. @options[:mode] || @options[:perm] || default_value end |
#slice(*args) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 |
# File 'lib/sugar_utils/file/write_options.rb', line 50 def slice(*args) keys = args.flatten.compact @options.select { |k| keys.include?(k) } end |