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 collapse

Attributes inherited from BasicData

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasActions

#actions

Methods inherited from BasicData

#==, #attributes, client, #collection_name, #collection_path, create, #element_name, #element_path, #hash, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attrs, #save, save, schema, #schema, #update!, #update_fields

Methods included from JsonUtils

included

Constructor Details

This class inherits a constructor from Trello::BasicData

Instance Attribute Details

#board_idString (readonly)

Returns A 24-character hex string.

Returns:

  • (String)

    A 24-character hex string



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trello/list.rb', line 20

class List < BasicData
  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true

    # Writable
    attribute :name
    attribute :pos
    attribute :board_id, remote_key: 'idBoard'

    # Writable but for create only
    attribute :source_list_id, create_only: true, remote_key: 'idListSource'

    # Writable but for update only
    attribute :closed, update_only: true
    attribute :subscribed, update_only: true
  end

  validates_presence_of :id, :name, :board_id
  validates_length_of   :name, in: 1..16_384

  include HasActions

  class << self
    # Finds a specific list, given an id.
    #
    # @param [id] id the list's ID on Trello (24-character hex string).
    # @param [Hash] params
    def find(id, params = {})
      client.find(:list, id, params)
    end
  end

  # Check if the list is not active anymore.
  def closed?
    closed
  end

  def close
    self.closed = true
  end

  def close!
    close
    save
  end

  # Return the board the list is connected to.
  one :board, path: :boards, using: :board_id

  # Returns all the cards on this list.
  #
  # The options hash may have a filter key which can have its value set as any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  many :cards, filter: :open

  def move_all_cards(other_list)
    client.post("/lists/#{id}/moveAllCards", {
      idBoard: other_list.board_id,
      idList: other_list.id
     })
  end

  # Move list to another board. Accepts a `Trello::Board` or an id string.
  def move_to_board(board)
    board = board.id unless board.is_a?(String)

    client.put("/lists/#{id}/idBoard", value: board)
  end

  # Archives all the cards of the list
  def archive_all_cards
    client.post("/lists/#{id}/archiveAllCards")
  end

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

#closedBoolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trello/list.rb', line 20

class List < BasicData
  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true

    # Writable
    attribute :name
    attribute :pos
    attribute :board_id, remote_key: 'idBoard'

    # Writable but for create only
    attribute :source_list_id, create_only: true, remote_key: 'idListSource'

    # Writable but for update only
    attribute :closed, update_only: true
    attribute :subscribed, update_only: true
  end

  validates_presence_of :id, :name, :board_id
  validates_length_of   :name, in: 1..16_384

  include HasActions

  class << self
    # Finds a specific list, given an id.
    #
    # @param [id] id the list's ID on Trello (24-character hex string).
    # @param [Hash] params
    def find(id, params = {})
      client.find(:list, id, params)
    end
  end

  # Check if the list is not active anymore.
  def closed?
    closed
  end

  def close
    self.closed = true
  end

  def close!
    close
    save
  end

  # Return the board the list is connected to.
  one :board, path: :boards, using: :board_id

  # Returns all the cards on this list.
  #
  # The options hash may have a filter key which can have its value set as any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  many :cards, filter: :open

  def move_all_cards(other_list)
    client.post("/lists/#{id}/moveAllCards", {
      idBoard: other_list.board_id,
      idList: other_list.id
     })
  end

  # Move list to another board. Accepts a `Trello::Board` or an id string.
  def move_to_board(board)
    board = board.id unless board.is_a?(String)

    client.put("/lists/#{id}/idBoard", value: board)
  end

  # Archives all the cards of the list
  def archive_all_cards
    client.post("/lists/#{id}/archiveAllCards")
  end

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

#idString (readonly)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trello/list.rb', line 20

class List < BasicData
  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true

    # Writable
    attribute :name
    attribute :pos
    attribute :board_id, remote_key: 'idBoard'

    # Writable but for create only
    attribute :source_list_id, create_only: true, remote_key: 'idListSource'

    # Writable but for update only
    attribute :closed, update_only: true
    attribute :subscribed, update_only: true
  end

  validates_presence_of :id, :name, :board_id
  validates_length_of   :name, in: 1..16_384

  include HasActions

  class << self
    # Finds a specific list, given an id.
    #
    # @param [id] id the list's ID on Trello (24-character hex string).
    # @param [Hash] params
    def find(id, params = {})
      client.find(:list, id, params)
    end
  end

  # Check if the list is not active anymore.
  def closed?
    closed
  end

  def close
    self.closed = true
  end

  def close!
    close
    save
  end

  # Return the board the list is connected to.
  one :board, path: :boards, using: :board_id

  # Returns all the cards on this list.
  #
  # The options hash may have a filter key which can have its value set as any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  many :cards, filter: :open

  def move_all_cards(other_list)
    client.post("/lists/#{id}/moveAllCards", {
      idBoard: other_list.board_id,
      idList: other_list.id
     })
  end

  # Move list to another board. Accepts a `Trello::Board` or an id string.
  def move_to_board(board)
    board = board.id unless board.is_a?(String)

    client.put("/lists/#{id}/idBoard", value: board)
  end

  # Archives all the cards of the list
  def archive_all_cards
    client.post("/lists/#{id}/archiveAllCards")
  end

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

#nameString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trello/list.rb', line 20

class List < BasicData
  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true

    # Writable
    attribute :name
    attribute :pos
    attribute :board_id, remote_key: 'idBoard'

    # Writable but for create only
    attribute :source_list_id, create_only: true, remote_key: 'idListSource'

    # Writable but for update only
    attribute :closed, update_only: true
    attribute :subscribed, update_only: true
  end

  validates_presence_of :id, :name, :board_id
  validates_length_of   :name, in: 1..16_384

  include HasActions

  class << self
    # Finds a specific list, given an id.
    #
    # @param [id] id the list's ID on Trello (24-character hex string).
    # @param [Hash] params
    def find(id, params = {})
      client.find(:list, id, params)
    end
  end

  # Check if the list is not active anymore.
  def closed?
    closed
  end

  def close
    self.closed = true
  end

  def close!
    close
    save
  end

  # Return the board the list is connected to.
  one :board, path: :boards, using: :board_id

  # Returns all the cards on this list.
  #
  # The options hash may have a filter key which can have its value set as any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  many :cards, filter: :open

  def move_all_cards(other_list)
    client.post("/lists/#{id}/moveAllCards", {
      idBoard: other_list.board_id,
      idList: other_list.id
     })
  end

  # Move list to another board. Accepts a `Trello::Board` or an id string.
  def move_to_board(board)
    board = board.id unless board.is_a?(String)

    client.put("/lists/#{id}/idBoard", value: board)
  end

  # Archives all the cards of the list
  def archive_all_cards
    client.post("/lists/#{id}/archiveAllCards")
  end

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

#posObject

Returns:

  • (Object)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trello/list.rb', line 20

class List < BasicData
  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true

    # Writable
    attribute :name
    attribute :pos
    attribute :board_id, remote_key: 'idBoard'

    # Writable but for create only
    attribute :source_list_id, create_only: true, remote_key: 'idListSource'

    # Writable but for update only
    attribute :closed, update_only: true
    attribute :subscribed, update_only: true
  end

  validates_presence_of :id, :name, :board_id
  validates_length_of   :name, in: 1..16_384

  include HasActions

  class << self
    # Finds a specific list, given an id.
    #
    # @param [id] id the list's ID on Trello (24-character hex string).
    # @param [Hash] params
    def find(id, params = {})
      client.find(:list, id, params)
    end
  end

  # Check if the list is not active anymore.
  def closed?
    closed
  end

  def close
    self.closed = true
  end

  def close!
    close
    save
  end

  # Return the board the list is connected to.
  one :board, path: :boards, using: :board_id

  # Returns all the cards on this list.
  #
  # The options hash may have a filter key which can have its value set as any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  many :cards, filter: :open

  def move_all_cards(other_list)
    client.post("/lists/#{id}/moveAllCards", {
      idBoard: other_list.board_id,
      idList: other_list.id
     })
  end

  # Move list to another board. Accepts a `Trello::Board` or an id string.
  def move_to_board(board)
    board = board.id unless board.is_a?(String)

    client.put("/lists/#{id}/idBoard", value: board)
  end

  # Archives all the cards of the list
  def archive_all_cards
    client.post("/lists/#{id}/archiveAllCards")
  end

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

#source_list_id=(value) ⇒ String (writeonly)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trello/list.rb', line 20

class List < BasicData
  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true

    # Writable
    attribute :name
    attribute :pos
    attribute :board_id, remote_key: 'idBoard'

    # Writable but for create only
    attribute :source_list_id, create_only: true, remote_key: 'idListSource'

    # Writable but for update only
    attribute :closed, update_only: true
    attribute :subscribed, update_only: true
  end

  validates_presence_of :id, :name, :board_id
  validates_length_of   :name, in: 1..16_384

  include HasActions

  class << self
    # Finds a specific list, given an id.
    #
    # @param [id] id the list's ID on Trello (24-character hex string).
    # @param [Hash] params
    def find(id, params = {})
      client.find(:list, id, params)
    end
  end

  # Check if the list is not active anymore.
  def closed?
    closed
  end

  def close
    self.closed = true
  end

  def close!
    close
    save
  end

  # Return the board the list is connected to.
  one :board, path: :boards, using: :board_id

  # Returns all the cards on this list.
  #
  # The options hash may have a filter key which can have its value set as any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  many :cards, filter: :open

  def move_all_cards(other_list)
    client.post("/lists/#{id}/moveAllCards", {
      idBoard: other_list.board_id,
      idList: other_list.id
     })
  end

  # Move list to another board. Accepts a `Trello::Board` or an id string.
  def move_to_board(board)
    board = board.id unless board.is_a?(String)

    client.put("/lists/#{id}/idBoard", value: board)
  end

  # Archives all the cards of the list
  def archive_all_cards
    client.post("/lists/#{id}/archiveAllCards")
  end

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

#subscribed=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trello/list.rb', line 20

class List < BasicData
  schema do
    # Readonly
    attribute :id, readonly: true, primary_key: true

    # Writable
    attribute :name
    attribute :pos
    attribute :board_id, remote_key: 'idBoard'

    # Writable but for create only
    attribute :source_list_id, create_only: true, remote_key: 'idListSource'

    # Writable but for update only
    attribute :closed, update_only: true
    attribute :subscribed, update_only: true
  end

  validates_presence_of :id, :name, :board_id
  validates_length_of   :name, in: 1..16_384

  include HasActions

  class << self
    # Finds a specific list, given an id.
    #
    # @param [id] id the list's ID on Trello (24-character hex string).
    # @param [Hash] params
    def find(id, params = {})
      client.find(:list, id, params)
    end
  end

  # Check if the list is not active anymore.
  def closed?
    closed
  end

  def close
    self.closed = true
  end

  def close!
    close
    save
  end

  # Return the board the list is connected to.
  one :board, path: :boards, using: :board_id

  # Returns all the cards on this list.
  #
  # The options hash may have a filter key which can have its value set as any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  many :cards, filter: :open

  def move_all_cards(other_list)
    client.post("/lists/#{id}/moveAllCards", {
      idBoard: other_list.board_id,
      idList: other_list.id
     })
  end

  # Move list to another board. Accepts a `Trello::Board` or an id string.
  def move_to_board(board)
    board = board.id unless board.is_a?(String)

    client.put("/lists/#{id}/idBoard", value: board)
  end

  # Archives all the cards of the list
  def archive_all_cards
    client.post("/lists/#{id}/archiveAllCards")
  end

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

Class Method Details

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

Finds a specific list, given an id.

Parameters:

  • id (id)

    the list’s ID on Trello (24-character hex string).

  • params (Hash) (defaults to: {})


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

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

Instance Method Details

#archive_all_cardsObject

Archives all the cards of the list



92
93
94
# File 'lib/trello/list.rb', line 92

def archive_all_cards
  client.post("/lists/#{id}/archiveAllCards")
end

#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

#move_all_cards(other_list) ⇒ Object



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

def move_all_cards(other_list)
  client.post("/lists/#{id}/moveAllCards", {
    idBoard: other_list.board_id,
    idList: other_list.id
   })
end

#move_to_board(board) ⇒ Object

Move list to another board. Accepts a ‘Trello::Board` or an id string.



85
86
87
88
89
# File 'lib/trello/list.rb', line 85

def move_to_board(board)
  board = board.id unless board.is_a?(String)

  client.put("/lists/#{id}/idBoard", value: board)
end

#request_prefixObject

:nodoc:



97
98
99
# File 'lib/trello/list.rb', line 97

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