Class: Fastererer::Explanation
- Inherits:
-
Object
- Object
- Fastererer::Explanation
- Defined in:
- lib/fastererer/explanation.rb
Instance Attribute Summary collapse
-
#offense_name ⇒ Object
readonly
Returns the value of attribute offense_name.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(offense_name) ⇒ Explanation
constructor
A new instance of Explanation.
- #rule_name ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(offense_name) ⇒ Explanation
Returns a new instance of Explanation.
15 16 17 18 |
# File 'lib/fastererer/explanation.rb', line 15 def initialize(offense_name) @offense_name = offense_name.to_sym @row = RuleCatalog.fetch(@offense_name) end |
Instance Attribute Details
#offense_name ⇒ Object (readonly)
Returns the value of attribute offense_name.
13 14 15 |
# File 'lib/fastererer/explanation.rb', line 13 def offense_name @offense_name end |
Class Method Details
.for(offense_name) ⇒ Object
8 9 10 11 |
# File 'lib/fastererer/explanation.rb', line 8 def self.for(offense_name) @instances ||= {} @instances[offense_name.to_sym] ||= new(offense_name) end |
Instance Method Details
#description ⇒ Object
20 21 22 |
# File 'lib/fastererer/explanation.rb', line 20 def description row.fetch('description') end |
#rule_name ⇒ Object
28 29 30 |
# File 'lib/fastererer/explanation.rb', line 28 def rule_name @rule_name ||= RuleName.from(offense_name) end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/fastererer/explanation.rb', line 32 def to_s "#{rule_name}: #{description.delete_suffix('.')}. (#{url})" end |
#url ⇒ Object
24 25 26 |
# File 'lib/fastererer/explanation.rb', line 24 def url row.fetch('url') end |