class Trello::Member
Attributes
attributes[RW]
Public Class Methods
find(username)
click to toggle source
# File lib/trello-lite/member.rb, line 19 def self.find(username) @username = username Trello.find_member(username) end
new(attrs = {})
click to toggle source
to keep things pragmatic, @attributes holds the json a cool feature in the future is to use metaprogramming to automatically create instance methods, including an instance_methods method to help the user better understand the API.
# File lib/trello-lite/member.rb, line 9 def initialize(attrs = {}) @attributes = attrs @boards = [] @organizations = [] end
Public Instance Methods
bio()
click to toggle source
# File lib/trello-lite/member.rb, line 34 def bio attributes[:bio] end
boards(number = "none")
click to toggle source
just returns an array for now - would be cool to use activemodel
# File lib/trello-lite/member.rb, line 43 def boards(number = "none") attributes[:idBoards].each_with_index do |id_board, idx| number == "none" ? number = attributes[:idBoards].size : number board_number = idx + 1 @boards << Board.new(id_board) break if board_number == number end @boards end
credentials()
click to toggle source
# File lib/trello-lite/member.rb, line 15 def credentials Trello.credentials end
find(username)
click to toggle source
# File lib/trello-lite/member.rb, line 24 def find(username) url = "https://api.trello.com/1/members/#{username}?fields=all&organizations=members&organization_fields=all&#{credentials}" @attributes = Trello.parse(url) self end
find_board(name)
click to toggle source
# File lib/trello-lite/member.rb, line 53 def find_board(name) board = nil attributes[:idBoards].each_with_index do |id_board, idx| board_number = idx + 1 Board.new(id_board).name.downcase.include?(name.downcase) ? board = Board.new(id_board) : next break end board end
full_name()
click to toggle source
# File lib/trello-lite/member.rb, line 30 def full_name attributes[:fullName] end
get_orgs_by_name(name)
click to toggle source
# File lib/trello-lite/member.rb, line 70 def get_orgs_by_name(name) organizations.select { |org| org.display_name.include?(name) } end
organizations()
click to toggle source
# File lib/trello-lite/member.rb, line 63 def organizations attributes[:organizations].each do |org| @organizations << Organization.new(org) end @organizations end
username()
click to toggle source
# File lib/trello-lite/member.rb, line 38 def username @username ||= attributes[:username] end