Class: CeilingCat::User
- Inherits:
-
Object
- Object
- CeilingCat::User
- Defined in:
- lib/ceiling_cat/user.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
-
#initialize(name, opts = {}) ⇒ User
constructor
A new instance of User.
- #is_guest? ⇒ Boolean
- #is_registered? ⇒ Boolean
- #short_name ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, opts = {}) ⇒ User
Returns a new instance of User.
5 6 7 8 9 |
# File 'lib/ceiling_cat/user.rb', line 5 def initialize(name, opts={}) @name = name @id = opts[:id] || rand(10000000) @role = opts[:role] || "guest" end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/ceiling_cat/user.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ceiling_cat/user.rb', line 3 def name @name end |
#role ⇒ Object
Returns the value of attribute role.
3 4 5 |
# File 'lib/ceiling_cat/user.rb', line 3 def role @role end |
Instance Method Details
#is_guest? ⇒ Boolean
23 24 25 |
# File 'lib/ceiling_cat/user.rb', line 23 def is_guest? @role.to_s.downcase == 'guest' || @type.to_s.nil? end |
#is_registered? ⇒ Boolean
19 20 21 |
# File 'lib/ceiling_cat/user.rb', line 19 def is_registered? @role.to_s.downcase == 'member' end |
#short_name ⇒ Object
15 16 17 |
# File 'lib/ceiling_cat/user.rb', line 15 def short_name @name.to_s.split.compact.first end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/ceiling_cat/user.rb', line 11 def to_s short_name end |