Class: Cwsrb::User
- Inherits:
-
Object
- Object
- Cwsrb::User
- Defined in:
- lib/cwsrb/data.rb
Overview
The User class represents a member of ConWorkShop.
Instance Attribute Summary collapse
-
#bio ⇒ String
readonly
The User's bio, max 1000 characters.
-
#country ⇒ String
readonly
The User's country.
-
#gender ⇒ String
readonly
The User's gender, one of "Male", "Female", "Cyborg" or "Other".
-
#id ⇒ String, Integer
readonly
The User's ID.
-
#karma ⇒ Array<(Integer, Integer)>
readonly
The User's karma counts; first one is upvotes and second one is downvotes.
-
#name ⇒ String
readonly
The User's name.
Instance Method Summary collapse
-
#generate_link ⇒ String
Generates a CWS link to this user.
-
#initialize(id: '', name: '', gender: 'Other', bio: '', country: 'Unknown', karma: [0, 0]) ⇒ User
constructor
Initializes a new User instance with an options hash.
-
#inspect ⇒ String
inspect method, with all of User's attributes.
Constructor Details
#initialize(id: '', name: '', gender: 'Other', bio: '', country: 'Unknown', karma: [0, 0]) ⇒ User
Initializes a new User instance with an options hash.
38 39 40 41 42 43 44 45 |
# File 'lib/cwsrb/data.rb', line 38 def initialize(id: '', name: '', gender: 'Other', bio: '', country: 'Unknown', karma: [0, 0]) @id = id @name = name @gender = gender @bio = bio @country = country @karma = karma end |
Instance Attribute Details
#bio ⇒ String (readonly)
Returns The User's bio, max 1000 characters.
17 18 19 |
# File 'lib/cwsrb/data.rb', line 17 def bio @bio end |
#country ⇒ String (readonly)
Returns The User's country.
20 21 22 |
# File 'lib/cwsrb/data.rb', line 20 def country @country end |
#gender ⇒ String (readonly)
Returns The User's gender, one of "Male", "Female", "Cyborg" or "Other".
14 15 16 |
# File 'lib/cwsrb/data.rb', line 14 def gender @gender end |
#id ⇒ String, Integer (readonly)
Returns The User's ID.
7 8 9 |
# File 'lib/cwsrb/data.rb', line 7 def id @id end |
#karma ⇒ Array<(Integer, Integer)> (readonly)
Returns The User's karma counts; first one is upvotes and second one is downvotes.
24 25 26 |
# File 'lib/cwsrb/data.rb', line 24 def karma @karma end |
#name ⇒ String (readonly)
Returns The User's name.
10 11 12 |
# File 'lib/cwsrb/data.rb', line 10 def name @name end |
Instance Method Details
#generate_link ⇒ String
Generates a CWS link to this user.
49 50 51 |
# File 'lib/cwsrb/data.rb', line 49 def generate_link CWS_BASE + "/view_profile.php?m=#{@id}" end |
#inspect ⇒ String
56 57 58 |
# File 'lib/cwsrb/data.rb', line 56 def inspect "<User id=#{@id} name=#{@name} gender=#{gender} bio=#{bio} country=#{country} karma=#{karma}>" end |