Class: Rerout::Models::ProjectStats
- Inherits:
-
Object
- Object
- Rerout::Models::ProjectStats
- Defined in:
- lib/rerout/models.rb
Overview
Project-wide aggregate stats response.
Instance Attribute Summary collapse
-
#browsers ⇒ Object
readonly
Returns the value of attribute browsers.
-
#countries ⇒ Object
readonly
Returns the value of attribute countries.
-
#daily ⇒ Object
readonly
Returns the value of attribute daily.
-
#days ⇒ Object
readonly
Returns the value of attribute days.
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
-
#qr_scans ⇒ Object
readonly
Returns the value of attribute qr_scans.
-
#referrers ⇒ Object
readonly
Returns the value of attribute referrers.
-
#top_codes ⇒ Object
readonly
Returns the value of attribute top_codes.
-
#total_clicks ⇒ Object
readonly
Returns the value of attribute total_clicks.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(**attrs) ⇒ ProjectStats
constructor
A new instance of ProjectStats.
- #to_h ⇒ Object
Constructor Details
#initialize(**attrs) ⇒ ProjectStats
Returns a new instance of ProjectStats.
196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/rerout/models.rb', line 196 def initialize(**attrs) @days = attrs[:days] @total_clicks = attrs[:total_clicks] @qr_scans = attrs[:qr_scans] @daily = attrs[:daily].freeze @countries = attrs[:countries].freeze @referrers = attrs[:referrers].freeze @devices = attrs[:devices].freeze @browsers = attrs[:browsers].freeze @top_codes = attrs[:top_codes].freeze freeze end |
Instance Attribute Details
#browsers ⇒ Object (readonly)
Returns the value of attribute browsers.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def browsers @browsers end |
#countries ⇒ Object (readonly)
Returns the value of attribute countries.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def countries @countries end |
#daily ⇒ Object (readonly)
Returns the value of attribute daily.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def daily @daily end |
#days ⇒ Object (readonly)
Returns the value of attribute days.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def days @days end |
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def devices @devices end |
#qr_scans ⇒ Object (readonly)
Returns the value of attribute qr_scans.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def qr_scans @qr_scans end |
#referrers ⇒ Object (readonly)
Returns the value of attribute referrers.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def referrers @referrers end |
#top_codes ⇒ Object (readonly)
Returns the value of attribute top_codes.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def top_codes @top_codes end |
#total_clicks ⇒ Object (readonly)
Returns the value of attribute total_clicks.
193 194 195 |
# File 'lib/rerout/models.rb', line 193 def total_clicks @total_clicks end |
Class Method Details
.from_hash(hash) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/rerout/models.rb', line 209 def self.from_hash(hash) new( days: hash['days'], total_clicks: hash['total_clicks'], qr_scans: hash['qr_scans'], daily: (hash['daily'] || []).map { |d| DailyClicksPoint.from_hash(d) }, countries: (hash['countries'] || []).map { |b| StatsBreakdown.from_hash(b) }, referrers: (hash['referrers'] || []).map { |b| StatsBreakdown.from_hash(b) }, devices: (hash['devices'] || []).map { |b| StatsBreakdown.from_hash(b) }, browsers: (hash['browsers'] || []).map { |b| StatsBreakdown.from_hash(b) }, top_codes: (hash['top_codes'] || []).map { |b| StatsBreakdown.from_hash(b) } ) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
235 236 237 |
# File 'lib/rerout/models.rb', line 235 def ==(other) other.is_a?(ProjectStats) && other.to_h == to_h end |
#hash ⇒ Object
240 241 242 |
# File 'lib/rerout/models.rb', line 240 def hash to_h.hash end |
#to_h ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/rerout/models.rb', line 223 def to_h { days: days, total_clicks: total_clicks, qr_scans: qr_scans, daily: daily.map(&:to_h), countries: countries.map(&:to_h), referrers: referrers.map(&:to_h), devices: devices.map(&:to_h), browsers: browsers.map(&:to_h), top_codes: top_codes.map(&:to_h) } end |