Class: Kanboard::Board
- Inherits:
-
Object
- Object
- Kanboard::Board
- Defined in:
- lib/kanboard/board.rb
Instance Attribute Summary collapse
-
#all_cards ⇒ Object
Returns the value of attribute all_cards.
-
#project ⇒ Object
Returns the value of attribute project.
-
#statuses ⇒ Object
Returns the value of attribute statuses.
-
#swimlanes ⇒ Object
Returns the value of attribute swimlanes.
Instance Method Summary collapse
- #cards(status, swimlane) ⇒ Object
-
#cards_of(owner) ⇒ Object
return all the cards owned by owner.
-
#initialize ⇒ Board
constructor
A new instance of Board.
- #load(filename) ⇒ Object
-
#owners ⇒ Object
return all the owners mentioned in the input file.
Constructor Details
#initialize ⇒ Board
Returns a new instance of Board.
25 26 27 28 29 30 31 |
# File 'lib/kanboard/board.rb', line 25 def initialize @project = "" @statuses = [] # all statuses (h2. strings) defined in the input file @swimlanes = [] # all unique swim-lane (+ strings) defined in the input file @cards = Hash.new # cards organised by board position @all_cards = Array.new # all cards defined in the input file end |
Instance Attribute Details
#all_cards ⇒ Object
Returns the value of attribute all_cards.
23 24 25 |
# File 'lib/kanboard/board.rb', line 23 def all_cards @all_cards end |
#project ⇒ Object
Returns the value of attribute project.
23 24 25 |
# File 'lib/kanboard/board.rb', line 23 def project @project end |
#statuses ⇒ Object
Returns the value of attribute statuses.
23 24 25 |
# File 'lib/kanboard/board.rb', line 23 def statuses @statuses end |
#swimlanes ⇒ Object
Returns the value of attribute swimlanes.
23 24 25 |
# File 'lib/kanboard/board.rb', line 23 def swimlanes @swimlanes end |
Instance Method Details
#cards(status, swimlane) ⇒ Object
68 69 70 |
# File 'lib/kanboard/board.rb', line 68 def cards(status, swimlane) @cards[hash(status, swimlane)] || Array.new # so that we always return an array end |
#cards_of(owner) ⇒ Object
return all the cards owned by owner
82 83 84 |
# File 'lib/kanboard/board.rb', line 82 def cards_of(owner) @all_cards.select { |c| c.owner == owner } end |
#load(filename) ⇒ Object
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 |
# File 'lib/kanboard/board.rb', line 33 def load filename current_status = "" # current status File.open(filename).each do |line| # set the title to the first h1 found in the file match = line.match(/^h1\.[ ]+(.+)$/) if match and @project == "" @project = match[1] end # look for statuses and add them to the list of statuses. # don't bother about duplications match = line.match(/^h2\.[ ]+(.+)$/) if match @statuses << match[1] current_status = match[1] end # look for cards and manage them if line.start_with?('- ') # make sure we ignore YAML front matter ("---") card = Kanboard::Card.new(@project, @status, line) swimlane = card.swimlane owner = card.owner @swimlanes << swimlane unless @swimlanes.include? swimlane position = hash(current_status, swimlane) @cards[position] = Array.new unless @cards[position] @cards[position] << card @all_cards << card end end end |
#owners ⇒ Object
return all the owners mentioned in the input file
75 76 77 |
# File 'lib/kanboard/board.rb', line 75 def owners @all_cards.map { |c| c.owner }.uniq end |