Class: Trello::Item

Inherits:
BasicData show all
Defined in:
lib/trello/item.rb

Overview

An Item is a basic task that can be checked off and marked as completed.

Instance Attribute Summary collapse

Attributes inherited from BasicData

#client

Instance Method Summary collapse

Methods inherited from BasicData

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

Methods included from JsonUtils

included

Constructor Details

This class inherits a constructor from Trello::BasicData

Instance Attribute Details

#idString (readonly)

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/trello/item.rb', line 14

class Item < BasicData
  register_attributes :id, :name, :type, :state, :pos, readonly: [ :id, :name, :type, :state, :pos ]
  validates_presence_of :id, :type

  # Updates the fields of an item.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an item.
  def update_fields(fields)
    attributes[:id]           = fields['id']
    attributes[:card_id]      = fields['idCard']
    attributes[:checklist_id] = fields['idChecklist']
    attributes[:name]         = fields['name']
    attributes[:type]         = fields['type']
    attributes[:state]        = fields['state']
    attributes[:pos]          = fields['pos']
    self
  end

  def complete?
    state == "complete"
  end
end

#nameString (readonly)

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/trello/item.rb', line 14

class Item < BasicData
  register_attributes :id, :name, :type, :state, :pos, readonly: [ :id, :name, :type, :state, :pos ]
  validates_presence_of :id, :type

  # Updates the fields of an item.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an item.
  def update_fields(fields)
    attributes[:id]           = fields['id']
    attributes[:card_id]      = fields['idCard']
    attributes[:checklist_id] = fields['idChecklist']
    attributes[:name]         = fields['name']
    attributes[:type]         = fields['type']
    attributes[:state]        = fields['state']
    attributes[:pos]          = fields['pos']
    self
  end

  def complete?
    state == "complete"
  end
end

#posObject (readonly)

Returns:

  • (Object)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/trello/item.rb', line 14

class Item < BasicData
  register_attributes :id, :name, :type, :state, :pos, readonly: [ :id, :name, :type, :state, :pos ]
  validates_presence_of :id, :type

  # Updates the fields of an item.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an item.
  def update_fields(fields)
    attributes[:id]           = fields['id']
    attributes[:card_id]      = fields['idCard']
    attributes[:checklist_id] = fields['idChecklist']
    attributes[:name]         = fields['name']
    attributes[:type]         = fields['type']
    attributes[:state]        = fields['state']
    attributes[:pos]          = fields['pos']
    self
  end

  def complete?
    state == "complete"
  end
end

#stateObject (readonly)

Returns:

  • (Object)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/trello/item.rb', line 14

class Item < BasicData
  register_attributes :id, :name, :type, :state, :pos, readonly: [ :id, :name, :type, :state, :pos ]
  validates_presence_of :id, :type

  # Updates the fields of an item.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an item.
  def update_fields(fields)
    attributes[:id]           = fields['id']
    attributes[:card_id]      = fields['idCard']
    attributes[:checklist_id] = fields['idChecklist']
    attributes[:name]         = fields['name']
    attributes[:type]         = fields['type']
    attributes[:state]        = fields['state']
    attributes[:pos]          = fields['pos']
    self
  end

  def complete?
    state == "complete"
  end
end

#typeObject (readonly)

Returns:

  • (Object)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/trello/item.rb', line 14

class Item < BasicData
  register_attributes :id, :name, :type, :state, :pos, readonly: [ :id, :name, :type, :state, :pos ]
  validates_presence_of :id, :type

  # Updates the fields of an item.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an item.
  def update_fields(fields)
    attributes[:id]           = fields['id']
    attributes[:card_id]      = fields['idCard']
    attributes[:checklist_id] = fields['idChecklist']
    attributes[:name]         = fields['name']
    attributes[:type]         = fields['type']
    attributes[:state]        = fields['state']
    attributes[:pos]          = fields['pos']
    self
  end

  def complete?
    state == "complete"
  end
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/trello/item.rb', line 33

def complete?
  state == "complete"
end

#update_fields(fields) ⇒ Object

Updates the fields of an item.

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



22
23
24
25
26
27
28
29
30
31
# File 'lib/trello/item.rb', line 22

def update_fields(fields)
  attributes[:id]           = fields['id']
  attributes[:card_id]      = fields['idCard']
  attributes[:checklist_id] = fields['idChecklist']
  attributes[:name]         = fields['name']
  attributes[:type]         = fields['type']
  attributes[:state]        = fields['state']
  attributes[:pos]          = fields['pos']
  self
end