Class: Cwsrb::User

Inherits:
Object
  • Object
show all
Defined in:
lib/cwsrb/data.rb

Overview

The User class represents a member of ConWorkShop.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, name: nil, gender: 'Other', bio: '', country: 'Unknown', karma: [0, 0]) ⇒ User

Initializes a new User instance with an options hash.

Parameters:

  • id (String, Integer) (defaults to: nil)

    The user's ID: a bunch of numbers that may or may not be prefixed with 'S'.

  • name (String) (defaults to: nil)

    The user's name. Defaults to nil.

  • gender (String) (defaults to: 'Other')

    The user's gender, one of "Male", "Female", "Cyborg" or "Other". Defaults to "Other".

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

    The user's bio or about section. Defaults to an empty string.

  • country (String) (defaults to: 'Unknown')

    The user's country. Defaults to "Unknown".

  • karma (Array<(Integer, Integer)>) (defaults to: [0, 0])

    The user's karma counts (first is upvotes, second is downvotes). Defaults to zero for both.



30
31
32
33
34
35
36
37
# File 'lib/cwsrb/data.rb', line 30

def initialize(id: nil, name: nil, gender: 'Other', bio: '', country: 'Unknown', karma: [0, 0])
  @id = id
  @name = name
  @gender = gender
  @bio = bio
  @country = country
  @karma = karma
end

Instance Attribute Details

#bioString (readonly)

Returns The User's bio, max 1000 characters.

Returns:

  • (String)

    The User's bio, max 1000 characters



14
15
16
# File 'lib/cwsrb/data.rb', line 14

def bio
  @bio
end

#countryString (readonly)

Returns The User's country.

Returns:

  • (String)

    The User's country



17
18
19
# File 'lib/cwsrb/data.rb', line 17

def country
  @country
end

#genderString (readonly)

Returns The User's gender, one of "Male", "Female", "Cyborg" or "Other".

Returns:

  • (String)

    The User's gender, one of "Male", "Female", "Cyborg" or "Other"



11
12
13
# File 'lib/cwsrb/data.rb', line 11

def gender
  @gender
end

#idString, Integer (readonly)

Returns The User's ID.

Returns:

  • (String, Integer)

    The User's ID



5
6
7
# File 'lib/cwsrb/data.rb', line 5

def id
  @id
end

#karmaArray<(Integer, Integer)> (readonly)

Returns The User's karma counts; first one is upvotes and second one is downvotes.

Returns:

  • (Array<(Integer, Integer)>)

    The User's karma counts; first one is upvotes and second one is downvotes



20
21
22
# File 'lib/cwsrb/data.rb', line 20

def karma
  @karma
end

#nameString (readonly)

Returns The User's name.

Returns:

  • (String)

    The User's name



8
9
10
# File 'lib/cwsrb/data.rb', line 8

def name
  @name
end

Instance Method Details

#inspectString

Returns A more meaningful output than that of the default inspect method, with all of User's attributes.

Returns:

  • (String)

    A more meaningful output than that of the default inspect method, with all of User's attributes.



41
42
43
# File 'lib/cwsrb/data.rb', line 41

def inspect
  "<User id=#{@id} name=#{@name} gender=#{gender} bio=#{bio} country=#{country} karma=#{karma}>"
end