Class: CaseCheck::Reference
- Inherits:
-
Struct
- Object
- Struct
- CaseCheck::Reference
- Defined in:
- lib/case_check/reference.rb
Overview
abstract base class
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
-
#source ⇒ Object
Returns the value of attribute source.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #message ⇒ Object
-
#resolution ⇒ Object
Returns :exact, :case_insensitive, or nil depending on whether the reference could be resolved on a case_sensitive FS, only on a case_insensitive FS, or not at all.
- #substituted_text ⇒ Object
- #type_name ⇒ Object
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line
9 10 11 |
# File 'lib/case_check/reference.rb', line 9 def line @line end |
#source ⇒ Object
Returns the value of attribute source
9 10 11 |
# File 'lib/case_check/reference.rb', line 9 def source @source end |
#text ⇒ Object
Returns the value of attribute text
9 10 11 |
# File 'lib/case_check/reference.rb', line 9 def text @text end |
Class Method Details
.substitutions ⇒ Object
11 12 13 |
# File 'lib/case_check/reference.rb', line 11 def substitutions @substitutions ||= [] end |
Instance Method Details
#message ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/case_check/reference.rb', line 30 def start = case resolution when :exact "Exactly resolved" when :case_insensitive "Case-insensitively resolved" else "Unresolved" end msg = "#{start} #{type_name} on line #{line}" if resolution "#{msg} from #{text} to #{resolved_to}" else "#{msg}: #{text}" end end |
#resolution ⇒ Object
Returns :exact, :case_insensitive, or nil depending on whether the reference could be resolved on a case_sensitive FS, only on a case_insensitive FS, or not at all
25 26 27 28 |
# File 'lib/case_check/reference.rb', line 25 def resolution return nil unless resolved_to case_sensitive_match? ? :exact : :case_insensitive end |
#substituted_text ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/case_check/reference.rb', line 52 def substituted_text re, sub = CaseCheck::Reference.substitutions.detect { |expr, _| expr =~ text } if re text.sub(re, sub) else text end end |
#type_name ⇒ Object
48 49 50 |
# File 'lib/case_check/reference.rb', line 48 def type_name self.class.name.split('::').last.underscore.gsub('_', ' ') end |