Class: Trello::List

Inherits:
BasicData show all
Includes:
HasActions
Defined in:
lib/trello/list.rb

Overview

A List is a container which holds cards. Lists are items on a board.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasActions

#actions

Methods inherited from BasicData

#==, #initialize, many, one, #refresh!, register_attributes

Constructor Details

This class inherits a constructor from Trello::BasicData

Class Method Details

.create(options) ⇒ Object



16
17
18
19
# File 'lib/trello/list.rb', line 16

def create(options)
  new('name'    => options[:name],
      'idBoard' => options[:board_id]).save
end

.find(id) ⇒ Object

Finds a specific list, given an id.



12
13
14
# File 'lib/trello/list.rb', line 12

def find(id)
  super(:lists, id)
end

Instance Method Details

#closed?Boolean

Check if the list is not active anymore.

Returns:

  • (Boolean)


52
53
54
# File 'lib/trello/list.rb', line 52

def closed?
  closed
end

#request_prefixObject

:nodoc:



67
68
69
# File 'lib/trello/list.rb', line 67

def request_prefix
  "/lists/#{id}"
end

#saveObject



34
35
36
37
38
39
40
41
42
# File 'lib/trello/list.rb', line 34

def save
  return update! if id

  Client.post("/lists", {
    :name    => name,
    :closed  => closed || false,
    :idBoard => board_id
  }).json_into(self)
end

#update!Object



44
45
46
47
48
49
# File 'lib/trello/list.rb', line 44

def update!
  Client.put("/lists", {
    :name   => name,
    :closed => closed
  }).json_into(self)
end

#update_fields(fields) ⇒ Object

Updates the fields of a list.

Supply a hash of string keyed data retrieved from the Trello API representing a List.



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

def update_fields(fields)
  attributes[:id]       = fields['id']
  attributes[:name]     = fields['name']
  attributes[:closed]   = fields['closed']
  attributes[:board_id] = fields['idBoard']
  self
end