Class: MetzScan::Analyzers::Occurrence
- Inherits:
-
Struct
- Object
- Struct
- MetzScan::Analyzers::Occurrence
- Defined in:
- lib/metz_scan/analyzers/occurrence.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#line ⇒ Object
Returns the value of attribute line.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
7 8 9 |
# File 'lib/metz_scan/analyzers/occurrence.rb', line 7 def context @context end |
#line ⇒ Object
Returns the value of attribute line
7 8 9 |
# File 'lib/metz_scan/analyzers/occurrence.rb', line 7 def line @line end |
#path ⇒ Object
Returns the value of attribute path
7 8 9 |
# File 'lib/metz_scan/analyzers/occurrence.rb', line 7 def path @path end |
Class Method Details
.from(value, context: nil) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/metz_scan/analyzers/occurrence.rb', line 8 def self.from(value, context: nil) return value if value.is_a?(self) return nil unless value.respond_to?(:path) && value.path new(path: value.path, line: line_for(value), context: context) end |
.line_for(value) ⇒ Object
15 16 17 |
# File 'lib/metz_scan/analyzers/occurrence.rb', line 15 def self.line_for(value) value.line if value.respond_to?(:line) end |
Instance Method Details
#line_source ⇒ Object
23 24 25 |
# File 'lib/metz_scan/analyzers/occurrence.rb', line 23 def line_source line ? "source" : "fallback" end |
#report_line ⇒ Object
19 20 21 |
# File 'lib/metz_scan/analyzers/occurrence.rb', line 19 def report_line line || MetzScan::Analyzers::FALLBACK_LINE end |