Class: Rerout::Models::DailyClicksPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/rerout/models.rb

Overview

One day in a ‘daily` time-series.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(day:, clicks:, qr_scans:) ⇒ DailyClicksPoint

Returns a new instance of DailyClicksPoint.



89
90
91
92
93
94
# File 'lib/rerout/models.rb', line 89

def initialize(day:, clicks:, qr_scans:)
  @day = day
  @clicks = clicks
  @qr_scans = qr_scans
  freeze
end

Instance Attribute Details

#clicksObject (readonly)

Returns the value of attribute clicks.



87
88
89
# File 'lib/rerout/models.rb', line 87

def clicks
  @clicks
end

#dayObject (readonly)

Returns the value of attribute day.



87
88
89
# File 'lib/rerout/models.rb', line 87

def day
  @day
end

#qr_scansObject (readonly)

Returns the value of attribute qr_scans.



87
88
89
# File 'lib/rerout/models.rb', line 87

def qr_scans
  @qr_scans
end

Class Method Details

.from_hash(hash) ⇒ Object



96
97
98
# File 'lib/rerout/models.rb', line 96

def self.from_hash(hash)
  new(day: hash['day'], clicks: hash['clicks'], qr_scans: hash['qr_scans'])
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



104
105
106
107
# File 'lib/rerout/models.rb', line 104

def ==(other)
  other.is_a?(DailyClicksPoint) && other.day == day &&
    other.clicks == clicks && other.qr_scans == qr_scans
end

#hashObject



110
111
112
# File 'lib/rerout/models.rb', line 110

def hash
  [self.class, day, clicks, qr_scans].hash
end

#to_hObject



100
101
102
# File 'lib/rerout/models.rb', line 100

def to_h
  { day: day, clicks: clicks, qr_scans: qr_scans }
end