Class: Trello::Member
- Includes:
- HasActions
- Defined in:
- lib/trello/member.rb
Overview
A Member is a user of the Trello service.
Class Method Summary collapse
-
.find(id_or_username) ⇒ Object
Finds a user.
Instance Method Summary collapse
-
#avatar_url(options = { :size => :large }) ⇒ Object
Retrieve a URL to the avatar.
-
#request_prefix ⇒ Object
:nodoc:.
- #save ⇒ Object
- #update! ⇒ Object
-
#update_fields(fields) ⇒ Object
Update the fields of a member.
Methods included from HasActions
Methods inherited from BasicData
#==, #initialize, many, one, #refresh!, register_attributes
Constructor Details
This class inherits a constructor from Trello::BasicData
Class Method Details
.find(id_or_username) ⇒ Object
Finds a user
The argument may be specified as either an id or a username.
15 16 17 |
# File 'lib/trello/member.rb', line 15 def find(id_or_username) super(:members, id_or_username) end |
Instance Method Details
#avatar_url(options = { :size => :large }) ⇒ Object
Retrieve a URL to the avatar.
Valid values for options are:
:large (170x170)
:small (30x30)
39 40 41 42 |
# File 'lib/trello/member.rb', line 39 def avatar_url( = { :size => :large }) size = [:size] == :small ? 30 : 170 "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png" end |
#request_prefix ⇒ Object
:nodoc:
89 90 91 |
# File 'lib/trello/member.rb', line 89 def request_prefix "/members/#{id}" end |
#save ⇒ Object
74 75 76 77 78 79 |
# File 'lib/trello/member.rb', line 74 def save @previously_changed = changes @changed_attributes.clear return update! if id end |
#update! ⇒ Object
81 82 83 84 85 86 |
# File 'lib/trello/member.rb', line 81 def update! Client.put(request_prefix, { :fullName => full_name, :bio => bio }).json_into(self) end |
#update_fields(fields) ⇒ Object
Update the fields of a member.
Supply a hash of string keyed data retrieved from the Trello API representing an Member.
24 25 26 27 28 29 30 31 32 |
# File 'lib/trello/member.rb', line 24 def update_fields(fields) attributes[:id] = fields['id'] attributes[:full_name] = fields['fullName'] attributes[:username] = fields['username'] attributes[:avatar_id] = fields['avatarHash'] attributes[:bio] = fields['bio'] attributes[:url] = fields['url'] self end |