Class: Afterburn::Project
- Inherits:
-
Object
- Object
- Afterburn::Project
- Includes:
- Redis::Objects
- Defined in:
- lib/afterburn/project.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #disable! ⇒ Object
- #enable! ⇒ Object
- #enable=(enabled) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(board) ⇒ Project
constructor
A new instance of Project.
- #interval_series_json ⇒ Object
- #interval_timestamps ⇒ Object
-
#intervals ⇒ Object
TODO handle BoardIntervals not found.
- #lists ⇒ Object
- #name ⇒ Object
- #name=(name) ⇒ Object
-
#record_interval ⇒ Object
TODO test.
- #to_json ⇒ Object
- #update_attributes(attributes) ⇒ Object
Constructor Details
#initialize(board) ⇒ Project
Returns a new instance of Project.
27 28 29 |
# File 'lib/afterburn/project.rb', line 27 def initialize(board) @board = board end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
26 27 28 |
# File 'lib/afterburn/project.rb', line 26 def board @board end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/afterburn/project.rb', line 12 def id @id end |
Class Method Details
.by_member(member) ⇒ Object
18 19 20 |
# File 'lib/afterburn/project.rb', line 18 def self.by_member(member) member.boards.map { |board| Project.new(board) } end |
.by_member_name(member_name) ⇒ Object
14 15 16 |
# File 'lib/afterburn/project.rb', line 14 def self.by_member_name(member_name) Board.fetch_by_member(member_name).map { |board| Project.new(board) } end |
Instance Method Details
#disable! ⇒ Object
47 48 49 |
# File 'lib/afterburn/project.rb', line 47 def disable! enabled_value.value = nil end |
#enable! ⇒ Object
43 44 45 |
# File 'lib/afterburn/project.rb', line 43 def enable! enabled_value.value = "1" end |
#enable=(enabled) ⇒ Object
51 52 53 |
# File 'lib/afterburn/project.rb', line 51 def enable=(enabled) enabled == "1" ? enable! : disable! end |
#enabled? ⇒ Boolean
55 56 57 |
# File 'lib/afterburn/project.rb', line 55 def enabled? !!enabled_value.value end |
#interval_series_json ⇒ Object
89 90 91 |
# File 'lib/afterburn/project.rb', line 89 def interval_series_json ListIntervalSeries.new(lists, ).to_json end |
#interval_timestamps ⇒ Object
85 86 87 |
# File 'lib/afterburn/project.rb', line 85 def intervals.map(&:timestamp) end |
#intervals ⇒ Object
TODO handle BoardIntervals not found
72 73 74 |
# File 'lib/afterburn/project.rb', line 72 def intervals @intervals ||= BoardInterval.find_all(interval_set.members) end |
#lists ⇒ Object
59 60 61 |
# File 'lib/afterburn/project.rb', line 59 def lists @board.lists end |
#name ⇒ Object
39 40 41 |
# File 'lib/afterburn/project.rb', line 39 def name redis_name_value.value || @board.name end |
#name=(name) ⇒ Object
35 36 37 |
# File 'lib/afterburn/project.rb', line 35 def name=(name) redis_name_value.value = name end |
#record_interval ⇒ Object
TODO test
64 65 66 67 68 69 |
# File 'lib/afterburn/project.rb', line 64 def record_interval Time.now.tap do || interval = BoardInterval.record(@board, ) interval_set[interval.id] = .to_i end end |
#to_json ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/afterburn/project.rb', line 76 def to_json {}.tap do |hash| hash['id'] = id hash['name'] = name hash['categories'] = .map(&:to_date) hash['series'] = interval_series_json end end |
#update_attributes(attributes) ⇒ Object
93 94 95 96 97 |
# File 'lib/afterburn/project.rb', line 93 def update_attributes(attributes) attributes.each do |key, value| send("#{key}=", value) end end |