Class: CodeModels::SourcePosition
- Inherits:
-
Object
- Object
- CodeModels::SourcePosition
- Defined in:
- lib/codemodels/position.rb
Overview
A position is a pair of a begin and an end point
Instance Attribute Summary collapse
-
#begin_point ⇒ Object
Returns the value of attribute begin_point.
-
#end_point ⇒ Object
Returns the value of attribute end_point.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #begin_column ⇒ Object
- #begin_column=(column) ⇒ Object
- #begin_line ⇒ Object
- #begin_line=(line) ⇒ Object
- #end_column ⇒ Object
- #end_column=(column) ⇒ Object
- #end_line ⇒ Object
- #end_line=(line) ⇒ Object
- #eql?(other) ⇒ Boolean
- #get_code(artifact_code) ⇒ Object
-
#get_string(artifact_code) ⇒ Object
Deprecated, use get_code instead.
- #include?(other) ⇒ Boolean
-
#initialize(begin_point = nil, end_point = nil) ⇒ SourcePosition
constructor
A new instance of SourcePosition.
- #to_s ⇒ Object
Constructor Details
#initialize(begin_point = nil, end_point = nil) ⇒ SourcePosition
Returns a new instance of SourcePosition.
95 96 97 98 |
# File 'lib/codemodels/position.rb', line 95 def initialize(begin_point=nil,end_point=nil) @begin_point = begin_point @end_point = end_point end |
Instance Attribute Details
#begin_point ⇒ Object
Returns the value of attribute begin_point.
89 90 91 |
# File 'lib/codemodels/position.rb', line 89 def begin_point @begin_point end |
#end_point ⇒ Object
Returns the value of attribute end_point.
89 90 91 |
# File 'lib/codemodels/position.rb', line 89 def end_point @end_point end |
Class Method Details
.from_code_indexes(code, begin_index, end_index) ⇒ Object
91 92 93 |
# File 'lib/codemodels/position.rb', line 91 def self.from_code_indexes(code,begin_index,end_index) SourcePosition.new(SourcePoint.from_code_index(code,begin_index),SourcePoint.from_code_index(code,end_index)) end |
Instance Method Details
#==(other) ⇒ Object
127 128 129 |
# File 'lib/codemodels/position.rb', line 127 def ==(other) self.eql?(other) end |
#begin_column ⇒ Object
154 155 156 |
# File 'lib/codemodels/position.rb', line 154 def begin_column @begin_point.column end |
#begin_column=(column) ⇒ Object
105 106 107 108 |
# File 'lib/codemodels/position.rb', line 105 def begin_column=(column) @begin_point=SourcePoint.new unless @begin_point @begin_point.column = column end |
#begin_line ⇒ Object
146 147 148 |
# File 'lib/codemodels/position.rb', line 146 def begin_line @begin_point.line end |
#begin_line=(line) ⇒ Object
100 101 102 103 |
# File 'lib/codemodels/position.rb', line 100 def begin_line=(line) @begin_point=SourcePoint.new unless @begin_point @begin_point.line = line end |
#end_column ⇒ Object
158 159 160 |
# File 'lib/codemodels/position.rb', line 158 def end_column @end_point.column end |
#end_column=(column) ⇒ Object
115 116 117 118 |
# File 'lib/codemodels/position.rb', line 115 def end_column=(column) @end_point=SourcePoint.new unless @end_point @end_point.column = column end |
#end_line ⇒ Object
150 151 152 |
# File 'lib/codemodels/position.rb', line 150 def end_line @end_point.line end |
#end_line=(line) ⇒ Object
110 111 112 113 |
# File 'lib/codemodels/position.rb', line 110 def end_line=(line) @end_point=SourcePoint.new unless @end_point @end_point.line = line end |
#eql?(other) ⇒ Boolean
121 122 123 124 125 |
# File 'lib/codemodels/position.rb', line 121 def eql?(other) return false unless other.respond_to?(:begin_point) return false unless other.respond_to?(:end_point) other.begin_point==begin_point && other.end_point==end_point end |
#get_code(artifact_code) ⇒ Object
140 141 142 143 144 |
# File 'lib/codemodels/position.rb', line 140 def get_code(artifact_code) as = @begin_point.to_absolute_index(artifact_code) ae = @end_point.to_absolute_index(artifact_code) artifact_code[as..ae] end |
#get_string(artifact_code) ⇒ Object
Deprecated, use get_code instead
136 137 138 |
# File 'lib/codemodels/position.rb', line 136 def get_string(artifact_code) get_code(artifact_code) end |
#include?(other) ⇒ Boolean
162 163 164 |
# File 'lib/codemodels/position.rb', line 162 def include?(other) (self.begin_point <= other.begin_point) && (self.end_point >= other.end_point) end |
#to_s ⇒ Object
131 132 133 |
# File 'lib/codemodels/position.rb', line 131 def to_s "from #{@begin_point} to #{@end_point}" end |