Class: TrustLevel3Requirements::PenaltyCounts

Inherits:
Object
  • Object
show all
Defined in:
app/models/trust_level3_requirements.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, row) ⇒ PenaltyCounts

Returns a new instance of PenaltyCounts.



9
10
11
12
13
14
15
16
17
# File 'app/models/trust_level3_requirements.rb', line 9

def initialize(user, row)
  @silenced = row["silence_count"] || 0
  @suspended = row["suspend_count"] || 0

  # If penalty started more than 6 months ago and still continues, it will
  # not be selected by the query from 'penalty_counts'.
  @silenced += 1 if @silenced == 0 && user.silenced?
  @suspended += 1 if @suspended == 0 && user.suspended?
end

Instance Attribute Details

#silencedObject (readonly)

Returns the value of attribute silenced.



7
8
9
# File 'app/models/trust_level3_requirements.rb', line 7

def silenced
  @silenced
end

#suspendedObject (readonly)

Returns the value of attribute suspended.



7
8
9
# File 'app/models/trust_level3_requirements.rb', line 7

def suspended
  @suspended
end

Instance Method Details

#totalObject



19
20
21
# File 'app/models/trust_level3_requirements.rb', line 19

def total
  @silenced + @suspended
end