Class: MetzScan::Analyzers::RepeatedBranching::DecisionSubject

Inherits:
Object
  • Object
show all
Defined in:
lib/metz_scan/analyzers/repeated_branching/decision_subject.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(decision) ⇒ DecisionSubject

Returns a new instance of DecisionSubject.



15
16
17
# File 'lib/metz_scan/analyzers/repeated_branching/decision_subject.rb', line 15

def initialize(decision)
  @decision = decision
end

Instance Attribute Details

#decisionObject (readonly)

Returns the value of attribute decision.



19
20
21
# File 'lib/metz_scan/analyzers/repeated_branching/decision_subject.rb', line 19

def decision
  @decision
end

Class Method Details

.for(decision) ⇒ Object



11
12
13
# File 'lib/metz_scan/analyzers/repeated_branching/decision_subject.rb', line 11

def self.for(decision)
  new(decision)
end

Instance Method Details

#generic?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/metz_scan/analyzers/repeated_branching/decision_subject.rb', line 21

def generic?
  kind == "generic"
end

#kindObject



25
26
27
28
29
30
# File 'lib/metz_scan/analyzers/repeated_branching/decision_subject.rb', line 25

def kind
  return "generic" if GENERIC_SUBJECTS.include?(decision)
  return "state" if SIMPLE_IDENTIFIER.match?(decision)

  "expression"
end

#labelObject



32
33
34
35
36
# File 'lib/metz_scan/analyzers/repeated_branching/decision_subject.rb', line 32

def label
  { "generic" => "generic branch subject",
    "state" => "state branch subject",
    "expression" => "expression subject" }.fetch(kind)
end

#summaryObject



38
39
40
41
42
# File 'lib/metz_scan/analyzers/repeated_branching/decision_subject.rb', line 38

def summary
  { "generic" => "Generic subject; use reported contexts before treating this as design pressure.",
    "state" => "State-like subject; repeated branch tables may describe a shared domain decision.",
    "expression" => "Expression subject; repeated computed conditions may deserve extraction." }.fetch(kind)
end