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.

Instance Attribute Summary

Attributes inherited from BasicData

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasActions

#actions

Methods inherited from BasicData

#==, client, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save

Constructor Details

This class inherits a constructor from Trello::BasicData

Class Method Details

.create(options) ⇒ Object



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

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

.find(id, params = {}) ⇒ Object

Finds a specific list, given an id.



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

def find(id, params = {})
  client.find(:list, id, params)
end

Instance Method Details

#closeObject



58
59
60
# File 'lib/trello/list.rb', line 58

def close
  self.closed = true
end

#close!Object



62
63
64
65
# File 'lib/trello/list.rb', line 62

def close!
  close
  save
end

#closed?Boolean

Check if the list is not active anymore.

Returns:

  • (Boolean)


54
55
56
# File 'lib/trello/list.rb', line 54

def closed?
  closed
end

#request_prefixObject

:nodoc:



78
79
80
# File 'lib/trello/list.rb', line 78

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

#saveObject



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

def save
  return update! if id

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

#update!Object



46
47
48
49
50
51
# File 'lib/trello/list.rb', line 46

def update!
  client.put("/lists/#{id}", {
    :name   => name,
    :closed => closed
  })
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.



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

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