Class: HeedKit::Roadmap
- Inherits:
-
Object
- Object
- HeedKit::Roadmap
- Defined in:
- lib/heedkit/roadmap.rb
Overview
The public roadmap for a project: ordered status columns, each a list of items.
Constant Summary collapse
- STATUSES =
Column order matches the product (Planned → In progress → Shipped).
%w[planned in_progress shipped].freeze
- LABELS =
{ "planned" => "Planned", "in_progress" => "In progress", "shipped" => "Shipped" }.freeze
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Class Method Summary collapse
Instance Method Summary collapse
- #each_column ⇒ Object
-
#initialize(project_name:, theme:, columns:) ⇒ Roadmap
constructor
A new instance of Roadmap.
- #primary_color ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(project_name:, theme:, columns:) ⇒ Roadmap
Returns a new instance of Roadmap.
25 26 27 28 29 |
# File 'lib/heedkit/roadmap.rb', line 25 def initialize(project_name:, theme:, columns:) @project_name = project_name @theme = theme @columns = columns end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
13 14 15 |
# File 'lib/heedkit/roadmap.rb', line 13 def columns @columns end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
13 14 15 |
# File 'lib/heedkit/roadmap.rb', line 13 def project_name @project_name end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
13 14 15 |
# File 'lib/heedkit/roadmap.rb', line 13 def theme @theme end |
Class Method Details
.from_payload(payload) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/heedkit/roadmap.rb', line 15 def self.from_payload(payload) cols = (payload["columns"] || {}).transform_values do |items| items.map do |i| RoadmapItem.new(id: i["id"], title: i["title"], description: i["description"], vote_count: i["vote_count"], tag: i["tag"]) end end new(project_name: payload["project_name"], theme: payload["theme"] || {}, columns: cols) end |
Instance Method Details
#each_column ⇒ Object
31 32 33 34 35 |
# File 'lib/heedkit/roadmap.rb', line 31 def each_column return enum_for(:each_column) unless block_given? STATUSES.each { |status| yield status, LABELS[status], (columns[status] || []) } end |
#primary_color ⇒ Object
37 38 39 |
# File 'lib/heedkit/roadmap.rb', line 37 def primary_color theme["primary"] || "#0d9488" end |
#total ⇒ Object
41 42 43 |
# File 'lib/heedkit/roadmap.rb', line 41 def total columns.values.sum(&:size) end |