Class: AnalyticsOps::Portfolio::Result
- Inherits:
-
Object
- Object
- AnalyticsOps::Portfolio::Result
- Defined in:
- lib/analytics_ops/portfolio.rb,
sig/analytics_ops.rbs
Overview
Immutable multi-property report result.
Instance Attribute Summary collapse
-
#date_ranges ⇒ Array[record]
readonly
Returns the value of attribute date_ranges.
-
#entries ⇒ Array[Entry]
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
-
#initialize(entries:, date_ranges:) ⇒ Result
constructor
A new instance of Result.
- #to_h ⇒ record
Constructor Details
#initialize(entries:, date_ranges:) ⇒ Result
Returns a new instance of Result.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/analytics_ops/portfolio.rb', line 15 def initialize(entries:, date_ranges:) unless entries.is_a?(Array) && entries.all?(Entry) raise ArgumentError, "entries must contain AnalyticsOps::Portfolio::Entry values" end raise ArgumentError, "date_ranges must be an array" unless date_ranges.is_a?(Array) @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.
13 14 15 |
# File 'lib/analytics_ops/portfolio.rb', line 13 def date_ranges @date_ranges end |
#entries ⇒ Array[Entry] (readonly)
Returns the value of attribute entries.
13 14 15 |
# File 'lib/analytics_ops/portfolio.rb', line 13 def entries @entries end |
Instance Method Details
#to_h ⇒ record
26 27 28 29 30 31 |
# File 'lib/analytics_ops/portfolio.rb', line 26 def to_h { "entries" => entries.map(&:to_h), "date_ranges" => date_ranges } end |