Class: Rerout::Models::StatsBreakdown

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

Overview

A breakdown bucket — ‘{ value: “ZA”, clicks: 42 }`.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, clicks:) ⇒ StatsBreakdown

Returns a new instance of StatsBreakdown.



254
255
256
257
258
# File 'lib/rerout/models.rb', line 254

def initialize(value:, clicks:)
  @value = value
  @clicks = clicks
  freeze
end

Instance Attribute Details

#clicksObject (readonly)

Returns the value of attribute clicks.



252
253
254
# File 'lib/rerout/models.rb', line 252

def clicks
  @clicks
end

#valueObject (readonly)

Returns the value of attribute value.



252
253
254
# File 'lib/rerout/models.rb', line 252

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object



260
261
262
# File 'lib/rerout/models.rb', line 260

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

Instance Method Details

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



268
269
270
# File 'lib/rerout/models.rb', line 268

def ==(other)
  other.is_a?(StatsBreakdown) && other.value == value && other.clicks == clicks
end

#hashObject



273
274
275
# File 'lib/rerout/models.rb', line 273

def hash
  [self.class, value, clicks].hash
end

#to_hObject



264
265
266
# File 'lib/rerout/models.rb', line 264

def to_h
  { value: value, clicks: clicks }
end