Class: AdLint::Location
- Inherits:
-
Object
- Object
- AdLint::Location
- Includes:
- Comparable
- Defined in:
- lib/adlint/location.rb
Overview
DESCRIPTION
Location identifier of tokens.
Instance Attribute Summary collapse
-
#appearance_column_no ⇒ Object
readonly
Returns the value of attribute appearance_column_no.
-
#column_no ⇒ Object
readonly
VALUE Integer – Column-no where this token appears.
-
#fpath ⇒ Object
readonly
VALUE Pathname – Path name of the file contains this token.
-
#line_no ⇒ Object
readonly
VALUE Integer – Line-no where this token appears.
Instance Method Summary collapse
- #<=>(rhs) ⇒ Object
- #eql?(rhs) ⇒ Boolean
- #hash ⇒ Object
- #in_analysis_target?(traits) ⇒ Boolean
-
#initialize(fpath = nil, line_no = nil, column_no = nil, appearance_column_no = column_no) ⇒ Location
constructor
Constructs a location identifier.
-
#inspect ⇒ Object
DESCRIPTION Converts this location to debugging dump representation.
-
#to_a ⇒ Object
DESCRIPTION Converts this location identifier to an array representation.
-
#to_s ⇒ Object
DESCRIPTION Converts this location to a human readable string representation.
Constructor Details
#initialize(fpath = nil, line_no = nil, column_no = nil, appearance_column_no = column_no) ⇒ Location
Constructs a location identifier.
- Param
-
fpath (Pathname) Path name of the file contains the token.
- Param
-
line_no (Integer) Line-no where the token appears.
- Param
-
column_no (Integer) Column-no where the token appears.
44 45 46 47 48 |
# File 'lib/adlint/location.rb', line 44 def initialize(fpath = nil, line_no = nil, column_no = nil, appearance_column_no = column_no) @fpath, @line_no, @column_no = fpath, line_no, column_no @appearance_column_no = appearance_column_no end |
Instance Attribute Details
#appearance_column_no ⇒ Object (readonly)
Returns the value of attribute appearance_column_no.
62 63 64 |
# File 'lib/adlint/location.rb', line 62 def appearance_column_no @appearance_column_no end |
#column_no ⇒ Object (readonly)
VALUE
Integer – Column-no where this token appears.
60 61 62 |
# File 'lib/adlint/location.rb', line 60 def column_no @column_no end |
#fpath ⇒ Object (readonly)
VALUE
Pathname – Path name of the file contains this token.
52 53 54 |
# File 'lib/adlint/location.rb', line 52 def fpath @fpath end |
#line_no ⇒ Object (readonly)
VALUE
Integer – Line-no where this token appears.
56 57 58 |
# File 'lib/adlint/location.rb', line 56 def line_no @line_no end |
Instance Method Details
#<=>(rhs) ⇒ Object
81 82 83 |
# File 'lib/adlint/location.rb', line 81 def <=>(rhs) self.to_a <=> rhs.to_a end |
#eql?(rhs) ⇒ Boolean
85 86 87 |
# File 'lib/adlint/location.rb', line 85 def eql?(rhs) self == rhs end |
#hash ⇒ Object
89 90 91 |
# File 'lib/adlint/location.rb', line 89 def hash to_a.hash end |
#in_analysis_target?(traits) ⇒ Boolean
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/adlint/location.rb', line 64 def in_analysis_target?(traits) if @fpath under_inclusion_paths?(@fpath, traits) && !under_exclusion_paths?(@fpath, traits) and !@fpath.identical?(traits.of_project.initial_header) && !@fpath.identical?(traits.of_compiler.initial_header) else false end end |
#inspect ⇒ Object
DESCRIPTION
Converts this location to debugging dump representation.
RETURN VALUE
String – String representation of this location identifier.
116 117 118 119 |
# File 'lib/adlint/location.rb', line 116 def inspect "#{@fpath ? @fpath : 'nil'}:" + "#{@line_no ? @line_no : 'nil'}:#{@column_no ? @column_no : 'nil'}" end |
#to_a ⇒ Object
DESCRIPTION
Converts this location identifier to an array representation.
RETURN VALUE
Array< Object > – Array representation of this location identifier.
98 99 100 |
# File 'lib/adlint/location.rb', line 98 def to_a [@fpath, @line_no, @column_no] end |
#to_s ⇒ Object
DESCRIPTION
Converts this location to a human readable string representation.
RETURN VALUE
String – String representation of this location identifier.
107 108 109 |
# File 'lib/adlint/location.rb', line 107 def to_s "#{@fpath}:#{@line_no}:#{@column_no}" end |