Class: Assistant::BrainMaintenance::Summary

Inherits:
Data
  • Object
show all
Defined in:
app/services/assistant/brain_maintenance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rejected: [], applied: [], pending_for_review: 0, weight_before: 0, weight_after: 0, error: nil) ⇒ Summary

Returns a new instance of Summary.



23
24
25
# File 'app/services/assistant/brain_maintenance.rb', line 23

def initialize(rejected: [], applied: [], pending_for_review: 0, weight_before: 0, weight_after: 0, error: nil)
  super
end

Instance Attribute Details

#appliedObject (readonly)

Returns the value of attribute applied

Returns:

  • (Object)

    the current value of applied



22
23
24
# File 'app/services/assistant/brain_maintenance.rb', line 22

def applied
  @applied
end

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



22
23
24
# File 'app/services/assistant/brain_maintenance.rb', line 22

def error
  @error
end

#pending_for_reviewObject (readonly)

Returns the value of attribute pending_for_review

Returns:

  • (Object)

    the current value of pending_for_review



22
23
24
# File 'app/services/assistant/brain_maintenance.rb', line 22

def pending_for_review
  @pending_for_review
end

#rejectedObject (readonly)

Returns the value of attribute rejected

Returns:

  • (Object)

    the current value of rejected



22
23
24
# File 'app/services/assistant/brain_maintenance.rb', line 22

def rejected
  @rejected
end

#weight_afterObject (readonly)

Returns the value of attribute weight_after

Returns:

  • (Object)

    the current value of weight_after



22
23
24
# File 'app/services/assistant/brain_maintenance.rb', line 22

def weight_after
  @weight_after
end

#weight_beforeObject (readonly)

Returns the value of attribute weight_before

Returns:

  • (Object)

    the current value of weight_before



22
23
24
# File 'app/services/assistant/brain_maintenance.rb', line 22

def weight_before
  @weight_before
end

Instance Method Details

#any_changes?Boolean

Returns:

  • (Boolean)


28
# File 'app/services/assistant/brain_maintenance.rb', line 28

def any_changes? = rejected.any? || applied.any?

#reportable?Boolean

Returns:

  • (Boolean)


29
# File 'app/services/assistant/brain_maintenance.rb', line 29

def reportable?  = any_changes? || pending_for_review.positive?

#success?Boolean

Returns:

  • (Boolean)


27
# File 'app/services/assistant/brain_maintenance.rb', line 27

def success?     = error.nil?

#tokens_savedObject



30
# File 'app/services/assistant/brain_maintenance.rb', line 30

def tokens_saved = [weight_before - weight_after, 0].max