Class: Wright::Util::FileOwner Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wright/util/file_owner.rb

Overview

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.

Helper class to support user:group notation in file owner strings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_and_group = nil, group = nil) ⇒ FileOwner

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 FileOwner.



12
13
14
15
# File 'lib/wright/util/file_owner.rb', line 12

def initialize(user_and_group = nil, group = nil)
  self.user_and_group = user_and_group
  self.group = group if group
end

Instance Attribute Details

#groupString, 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.

Returns the group’s name or gid.

Returns:

  • (String, Integer)

    the group’s name or gid



10
11
12
# File 'lib/wright/util/file_owner.rb', line 10

def group
  @group
end

#userString, 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.

Returns the user’s name or uid.

Returns:

  • (String, Integer)

    the user’s name or uid



7
8
9
# File 'lib/wright/util/file_owner.rb', line 7

def user
  @user
end

Instance Method Details

#user_and_group=(user_and_group) ⇒ void

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.

This method returns an undefined value.

Sets user and group simultaneously.

Examples:

owner = FileOwner.new

owner.user_and_group = 'user:group'
owner.user
# => "user"
owner.group
# => "group"

owner.user_and_group = 'newuser'
owner.user
# => "newuser"
owner.group
# => "group"

owner.user_and_group = 42
owner.user
# => 42

Parameters:

  • user_and_group (String, Integer)

    a user in user:group notation or a uid

Raises:

  • (ArgumentError)

    if the owner string contains more than one colon



44
45
46
47
48
# File 'lib/wright/util/file_owner.rb', line 44

def user_and_group=(user_and_group)
  user, group = split_user_and_group(user_and_group)
  self.user = user
  self.group = group if group
end