Class: Pain::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/pain/model.rb

Constant Summary collapse

MAX =
{
  bug_type: 7,
  likelihood: 5,
  impact: 5
}.freeze
INPUT_MESSAGE =
{
  bug_type: 'What kind of bug is this?',
  likelihood: 'How likely is this bug to occur?',
  impact: 'How much impact will this bug have?'
}.freeze
OPTIONS =
{
  bug_type: {
    1 => 'Documentation: a documentation issue',
    2 => 'Localization: missing translations',
    3 => 'Visual Polish: Aesthetic issues',
    4 => 'Balancing: allows poor usage strategy',
    5 => 'Minor UX: Impairs UX in secondary scenarios',
    6 => 'Major UX: Impairs UX in key scenarios',
    7 => 'Crash: Causes crash or data loss'
  },
  likelihood: {
    1 => 'Will affect almost no one',
    2 => 'Will only affect a few users',
    3 => 'Will affect average number of users',
    4 => 'Will affect most users',
    5 => 'Will affect all users'
  },

  impact: {
    1 => 'Nuisance: not a big deal but noticeable.',
    2 => 'A Pain: Users won\'t like this once they notice it.',
    3 => 'Affects Buy-in. Will show up in review. Clearly noticeable.',
    4 => 'A user would return the product. Should not deploy until fixed',
    5 => 'Affects system build'
  }
}.freeze

Instance Method Summary collapse

Instance Method Details

#choices_for(category) ⇒ Object



44
45
46
# File 'lib/pain/model.rb', line 44

def choices_for(category)
  OPTIONS[category]
end

#input_message(category) ⇒ Object



56
57
58
# File 'lib/pain/model.rb', line 56

def input_message(category)
  INPUT_MESSAGE[category]
end

#level_string(category, score) ⇒ Object



48
49
50
# File 'lib/pain/model.rb', line 48

def level_string(category, score)
  OPTIONS.dig(category, score)
end

#max_for(category) ⇒ Object



52
53
54
# File 'lib/pain/model.rb', line 52

def max_for(category)
  MAX[category]
end

#max_painObject



60
61
62
# File 'lib/pain/model.rb', line 60

def max_pain
  MAX.values.reduce(&:*)
end

#normalize(value, variable) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/pain/model.rb', line 68

def normalize(value, variable)
  value = value.to_i
  max   = MAX[variable]

  return nil if max.nil? || value.nil?
  return nil if value < 1
  return max if value > max

  value
end

#user_pain(type, likelihood, impact) ⇒ Object



64
65
66
# File 'lib/pain/model.rb', line 64

def user_pain(type, likelihood, impact)
  100 * (type * likelihood * impact) / max_pain
end