Class: Kanbantastic::Column

Inherits:
Base
  • Object
show all
Defined in:
lib/kanbantastic/column.rb

Constant Summary

Constants inherited from Base

Base::RECTIFY_TIME_FOR

Instance Attribute Summary collapse

Attributes inherited from Base

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#assign_attributes, find_project_id, #get, invalid_response_error, #post, #project_id, #put, request

Constructor Details

#initialize(config, options = {}) ⇒ Column

Returns a new instance of Column.



7
8
9
10
11
12
13
# File 'lib/kanbantastic/column.rb', line 7

def initialize(config, options={})
  super(config)
  @id = options[:id]
  @name = options[:name]
  @position = options[:position]
  self.valid?
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/kanbantastic/column.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/kanbantastic/column.rb', line 4

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



4
5
6
# File 'lib/kanbantastic/column.rb', line 4

def position
  @position
end

Class Method Details

.all(config) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/kanbantastic/column.rb', line 35

def self.all(config)
  collection = []
  response = request(:get, config, "/projects/#{config.project_id}/columns.json")
  response.each do |data|
    column = new(config, data)
    collection << column if column.valid?
  end
  return collection
end

.find(config, id) ⇒ Object



31
32
33
# File 'lib/kanbantastic/column.rb', line 31

def self.find(config, id)
  Kanbantastic::Column.all(config).select{|c| c.id == id }[0]
end

Instance Method Details

#==(column) ⇒ Object



27
28
29
# File 'lib/kanbantastic/column.rb', line 27

def ==(column)
  id == column.id
end

#first?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/kanbantastic/column.rb', line 15

def first?
  self.position == 1
end

#last?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/kanbantastic/column.rb', line 23

def last?
  Kanbantastic::Column.all(config).last.id == id
end

#second?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/kanbantastic/column.rb', line 19

def second?
  self.position == 2
end