Class: OffenseToCorrector::OffenseTemplate
- Inherits:
-
Object
- Object
- OffenseToCorrector::OffenseTemplate
- Defined in:
- lib/offense_to_corrector/offense_template.rb
Overview
ERB template for rendering a cop skeleton, may make this more useful later, but mostly quick templating for now.
Instance Method Summary collapse
-
#initialize(name: "autocorrector_template.erb") ⇒ OffenseTemplate
constructor
A new instance of OffenseTemplate.
- #render(class_name: "TODO", match_pattern:, error_message: "", node_type:, cop_type: "Lint", node_location: "selector", offense_severity: "warning") ⇒ Object
Constructor Details
#initialize(name: "autocorrector_template.erb") ⇒ OffenseTemplate
Returns a new instance of OffenseTemplate.
5 6 7 8 |
# File 'lib/offense_to_corrector/offense_template.rb', line 5 def initialize(name: "autocorrector_template.erb") @template = File.read(OffenseToCorrector.load_template(name)) @erb = ERB.new(@template) end |
Instance Method Details
#render(class_name: "TODO", match_pattern:, error_message: "", node_type:, cop_type: "Lint", node_location: "selector", offense_severity: "warning") ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/offense_to_corrector/offense_template.rb', line 10 def render( class_name: "TODO", match_pattern:, error_message: "", node_type:, cop_type: "Lint", node_location: "selector", offense_severity: "warning" ) @erb.result_with_hash( class_name:, match_pattern:, error_message:, node_type:, cop_type:, node_location:, offense_severity: ) end |