Class: Gas::User

Inherits:
Object
  • Object
show all
Defined in:
lib/gas/user.rb

Overview

Class that contains data for a git user

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, email, nickname = '') ⇒ User

Returns a new instance of User.

Parameters:

  • name (String)

    The name of the user

  • email (String)

    The email of the user

  • nickname (String) (defaults to: '')

    A nickname for the user, not used when parsing from gitconfig



11
12
13
14
15
16
# File 'lib/gas/user.rb', line 11

def initialize(name, email, nickname = '')
  @name = name
  @email = email
  @nickname = nickname

end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/gas/user.rb', line 5

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/gas/user.rb', line 5

def name
  @name
end

#nicknameObject (readonly)

Returns the value of attribute nickname.



5
6
7
# File 'lib/gas/user.rb', line 5

def nickname
  @nickname
end

Instance Method Details

#git_userString

Returns the git format of user

Returns:

  • (String)


20
21
22
# File 'lib/gas/user.rb', line 20

def git_user
  to_s false
end

#to_s(use_nickname = true) ⇒ String

Overides to_s to output in the correct format

Parameters:

  • use_nickname (Boolean) (defaults to: true)

    Defaults to true

Returns:

  • (String)


27
28
29
# File 'lib/gas/user.rb', line 27

def to_s(use_nickname = true)
  "      [#{use_nickname ? @nickname : 'user'}]\n         name = #{@name}\n         email = #{@email}"
end