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.



61
62
63
64
65
# File 'lib/rerout/models.rb', line 61

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

Instance Attribute Details

#clicksObject (readonly)

Returns the value of attribute clicks.



59
60
61
# File 'lib/rerout/models.rb', line 59

def clicks
  @clicks
end

#valueObject (readonly)

Returns the value of attribute value.



59
60
61
# File 'lib/rerout/models.rb', line 59

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object



67
68
69
# File 'lib/rerout/models.rb', line 67

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

Instance Method Details

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



75
76
77
# File 'lib/rerout/models.rb', line 75

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

#hashObject



80
81
82
# File 'lib/rerout/models.rb', line 80

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

#to_hObject



71
72
73
# File 'lib/rerout/models.rb', line 71

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