Class: AnalyticsOps::Portfolio::Collection
- Inherits:
-
Object
- Object
- AnalyticsOps::Portfolio::Collection
- Defined in:
- lib/analytics_ops/portfolio.rb,
sig/analytics_ops.rbs
Overview
Immutable generalized report or health collection across profiles.
Constant Summary collapse
- NAME =
/\A[a-z][a-z0-9_-]{0,71}\z/
Instance Attribute Summary collapse
-
#date_ranges ⇒ Array[record]
readonly
Returns the value of attribute date_ranges.
-
#entries ⇒ Array[ProfileResult]
readonly
Returns the value of attribute entries.
-
#kind ⇒ String
readonly
Returns the value of attribute kind.
-
#name ⇒ String
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(kind:, name:, entries:, date_ranges:) ⇒ Collection
constructor
A new instance of Collection.
- #success? ⇒ Boolean
- #to_h ⇒ record
Constructor Details
#initialize(kind:, name:, entries:, date_ranges:) ⇒ Collection
Returns a new instance of Collection.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/analytics_ops/portfolio.rb', line 45 def initialize(kind:, name:, entries:, date_ranges:) unless %w[report health].include?(kind) && name.is_a?(String) && NAME.match?(name) && entries.is_a?(Array) && entries.all?(ProfileResult) raise ArgumentError, "Invalid portfolio collection" end @kind = kind.dup.freeze @name = name.dup.freeze @entries = entries.dup.freeze @date_ranges = Canonical.immutable(date_ranges) freeze end |
Instance Attribute Details
#date_ranges ⇒ Array[record] (readonly)
Returns the value of attribute date_ranges.
43 44 45 |
# File 'lib/analytics_ops/portfolio.rb', line 43 def date_ranges @date_ranges end |
#entries ⇒ Array[ProfileResult] (readonly)
Returns the value of attribute entries.
43 44 45 |
# File 'lib/analytics_ops/portfolio.rb', line 43 def entries @entries end |
#kind ⇒ String (readonly)
Returns the value of attribute kind.
43 44 45 |
# File 'lib/analytics_ops/portfolio.rb', line 43 def kind @kind end |
#name ⇒ String (readonly)
Returns the value of attribute name.
43 44 45 |
# File 'lib/analytics_ops/portfolio.rb', line 43 def name @name end |
Instance Method Details
#success? ⇒ Boolean
58 59 60 |
# File 'lib/analytics_ops/portfolio.rb', line 58 def success? entries.all? { |entry| entry.status == "ok" } end |
#to_h ⇒ record
62 63 64 65 66 67 68 69 70 |
# File 'lib/analytics_ops/portfolio.rb', line 62 def to_h { "kind" => kind, "name" => name, "success" => success?, "date_ranges" => date_ranges, "entries" => entries.map(&:to_h) } end |