Class: Afterburn::BoardInterval
- Inherits:
-
Object
- Object
- Afterburn::BoardInterval
- Includes:
- Redis::Objects
- Defined in:
- lib/afterburn/board_interval.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #id ⇒ Object
-
#initialize(board, timestamp = Time.now) ⇒ BoardInterval
constructor
A new instance of BoardInterval.
- #list_metrics ⇒ Object
- #record! ⇒ Object
Constructor Details
#initialize(board, timestamp = Time.now) ⇒ BoardInterval
Returns a new instance of BoardInterval.
25 26 27 28 |
# File 'lib/afterburn/board_interval.rb', line 25 def initialize(board, = Time.now) @board = board @timestamp = end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
8 9 10 |
# File 'lib/afterburn/board_interval.rb', line 8 def board @board end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
8 9 10 |
# File 'lib/afterburn/board_interval.rb', line 8 def @timestamp end |
Class Method Details
.find(id) ⇒ Object
10 11 12 13 14 |
# File 'lib/afterburn/board_interval.rb', line 10 def self.find(id) board_id, = Base64.decode64(id).split(":") return nil if board_id.nil? new(Board.find(board_id), Time.at(.to_i)) end |
.find_all(ids) ⇒ Object
16 17 18 |
# File 'lib/afterburn/board_interval.rb', line 16 def self.find_all(ids) ids.map { |interval_id| find(interval_id) }.compact end |
.record(board, timestamp) ⇒ Object
TODO test
21 22 23 |
# File 'lib/afterburn/board_interval.rb', line 21 def self.record(board, ) new(board, ).tap { |board_interval| board_interval.record! } end |
Instance Method Details
#==(other) ⇒ Object
42 43 44 |
# File 'lib/afterburn/board_interval.rb', line 42 def ==(other) self.class == other.class && !other.id.nil? && self.id == other.id end |
#id ⇒ Object
30 31 32 |
# File 'lib/afterburn/board_interval.rb', line 30 def id @id ||= Base64.encode64("#{@board.id}:#{@timestamp.to_i}") end |
#list_metrics ⇒ Object
34 35 36 |
# File 'lib/afterburn/board_interval.rb', line 34 def list_metrics @list_metrics ||= ListMetric.(@board.lists, ) end |
#record! ⇒ Object
38 39 40 |
# File 'lib/afterburn/board_interval.rb', line 38 def record! list_metrics.map(&:count!) end |