Class: Trello::List

Inherits:
Object
  • Object
show all
Defined in:
lib/trello-lite/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ List

Returns a new instance of List.



5
6
7
8
9
10
11
12
# File 'lib/trello-lite/list.rb', line 5

def initialize(attrs = {})
  @attributes = attrs
  @cards = []
  @attributes[:cards].each do |card|
    card_obj = Card.new(card)
    @cards << card_obj
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/trello-lite/list.rb', line 3

def attributes
  @attributes
end

Instance Method Details

#cardsObject



22
23
24
# File 'lib/trello-lite/list.rb', line 22

def cards
  @cards
end

#cards_by_member(username) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/trello-lite/list.rb', line 26

def cards_by_member(username)
  members_cards = []
  @cards.each do |card|
    member_in_card = card.members.select { |member| member.username == username }
    next if member_in_card.empty?
    members_cards << card
  end
  members_cards
end

#find_card(name = "") ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/trello-lite/list.rb', line 36

def find_card(name = "")
  card_obj = nil
  cards.each do |card|
    card_obj = card if card.name == name
  end
  if card_obj.nil?
    puts "Card doesn't exist. Here are some card names."
    cards.each do |card|
      puts card.name
    end
  else
    card_obj
  end
end

#idObject



14
15
16
# File 'lib/trello-lite/list.rb', line 14

def id
  attributes[:id]
end

#nameObject



18
19
20
# File 'lib/trello-lite/list.rb', line 18

def name
  attributes[:name]
end