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

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



39
40
41
42
43
# File 'lib/wright/util/file_owner.rb', line 39

def user_and_group=(user_and_group)
  user, group = split_user_and_group(user_and_group)
  @user = user
  @group = group if group
end