Class: Kanbanize::Board

Inherits:
Object
  • Object
show all
Defined in:
lib/kanbanize/board.rb,
lib/kanbanize/board/cell.rb,
lib/kanbanize/board/lane.rb,
lib/kanbanize/board/column.rb

Defined Under Namespace

Classes: Cell, Column, Lane

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, attributes) ⇒ Board

Returns a new instance of Board.

Parameters:

  • api (Kanbanize::API)

    the API object the board attributes are retrieved from

  • attributes (Hash)

    the attributes of the board to be created

Raises:

  • (ArgumentError)

    if the id of the board is not specified

  • (ArgumentError)

    if the name of the board is not specified


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kanbanize/board.rb', line 14

def initialize(api, attributes)
  raise ArgumentError unless attributes['id']
  raise ArgumentError unless attributes['name']

  @api = api

  @id = attributes['id'].to_i if attributes['id']
  @name = attributes['name']

  initialize_structure
end

Instance Attribute Details

#idInteger (readonly)

Returns the id of the board.

Returns:

  • (Integer)

    the id of the board


5
6
7
# File 'lib/kanbanize/board.rb', line 5

def id
  @id
end

#nameString (readonly)

Returns the name of the board.

Returns:

  • (String)

    the name of the board


8
9
10
# File 'lib/kanbanize/board.rb', line 8

def name
  @name
end

Instance Method Details

#[](arg) ⇒ Kanbanize::Column Also known as: column

Get the specified column from the board

Parameters:

  • arg (String, Integer)

    the name or the index of the column

Returns:

  • (Kanbanize::Column)

    the specified column


60
61
62
# File 'lib/kanbanize/board.rb', line 60

def [](arg)
  @columns[arg] || @columns.select{|k,v| v.position == arg}.values.first
end

#lane(name) ⇒ Kanbanize::Lane

Get the specified lane from the board

Parameters:

  • name (String)

    the name of the lane

Returns:

  • (Kanbanize::Lane)

    the specified lane


69
70
71
# File 'lib/kanbanize/board.rb', line 69

def lane(name)
  @lanes[name]
end

#tasksArray<Kanbanize::Task>

Get the tasks currently on the board and cache them. If they have already been cached, returns them without fetching from the API.

Returns:


31
32
33
# File 'lib/kanbanize/board.rb', line 31

def tasks
  @tasks || tasks!
end

#tasks!Array<Kanbanize::Task>

Get the tasks currently on the board, fresh from the API.

Returns:


38
39
40
# File 'lib/kanbanize/board.rb', line 38

def tasks!
  @tasks = @api.get_all_tasks(@id).map{|t| Task.new(self, t)}
end

#version(name) ⇒ Array<Kanbanize::Task>?

Get the tasks archived in a specified version.

Parameters:

  • name (String)

    the name of the version to be fetched

Returns:

  • (Array<Kanbanize::Task>)

    if the version can be fetched

  • (nil)

    if the version doesn't exist


47
48
49
50
51
52
53
54
# File 'lib/kanbanize/board.rb', line 47

def version(name)
  tasks = @api.get_all_tasks(@id, :archive => true, :version => name)
  if tasks
    return tasks['task'].map{|t| Task.new(self, t)}
  else
    return nil
  end
end