Class: KanbanTool::Board
- Inherits:
-
Object
- Object
- KanbanTool::Board
- Defined in:
- lib/kanbantool/board.rb
Defined Under Namespace
Classes: Stage
Constant Summary collapse
- FIELDS =
%w{ id name description created_at version last_activity_on }
Instance Attribute Summary collapse
-
#stages ⇒ Object
readonly
Returns the value of attribute stages.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#stages ⇒ Object (readonly)
Returns the value of attribute stages.
9 10 11 |
# File 'lib/kanbantool/board.rb', line 9 def stages @stages end |
Class Method Details
.create_from_hash(hash) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/kanbantool/board.rb', line 11 def self.create_from_hash(hash) board = self.new board.load!(hash) board.load_stages!(hash["workflow_stages"]) unless hash["workflow_stages"].nil? board end |
Instance Method Details
#load!(hash) ⇒ Object
18 19 20 |
# File 'lib/kanbantool/board.rb', line 18 def load!(hash) FIELDS.each { |f| instance_variable_set("@#{f}".to_sym, hash[f]) } end |
#load_stages!(array) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/kanbantool/board.rb', line 22 def load_stages!(array) @stages = [] array.each do |s| @stages << Stage.new( s["id"], s["name"], s["description"], s["position"] ).freeze end end |
#stage(id) ⇒ Object
29 30 31 |
# File 'lib/kanbantool/board.rb', line 29 def stage(id) stages.first { |s| s.id == id } end |