Class: CodeModels::SourcePosition
- Inherits:
-
Object
- Object
- CodeModels::SourcePosition
- Defined in:
- lib/codemodels/position.rb
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_line ⇒ Object
- #eql?(other) ⇒ Boolean
- #get_string(s) ⇒ Object
- #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.
100 101 102 103 |
# File 'lib/codemodels/position.rb', line 100 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.
94 95 96 |
# File 'lib/codemodels/position.rb', line 94 def begin_point @begin_point end |
#end_point ⇒ Object
Returns the value of attribute end_point.
94 95 96 |
# File 'lib/codemodels/position.rb', line 94 def end_point @end_point end |
Class Method Details
.from_code_indexes(code, begin_index, end_index) ⇒ Object
96 97 98 |
# File 'lib/codemodels/position.rb', line 96 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
121 122 123 |
# File 'lib/codemodels/position.rb', line 121 def ==(other) self.eql?(other) end |
#begin_column ⇒ Object
143 144 145 |
# File 'lib/codemodels/position.rb', line 143 def begin_column @begin_point.column end |
#begin_column=(column) ⇒ Object
110 111 112 113 |
# File 'lib/codemodels/position.rb', line 110 def begin_column=(column) @begin_point=SourcePoint.new unless @begin_point @begin_point.column = column end |
#begin_line ⇒ Object
135 136 137 |
# File 'lib/codemodels/position.rb', line 135 def begin_line @begin_point.line end |
#begin_line=(line) ⇒ Object
105 106 107 108 |
# File 'lib/codemodels/position.rb', line 105 def begin_line=(line) @begin_point=SourcePoint.new unless @begin_point @begin_point.line = line end |
#end_column ⇒ Object
147 148 149 |
# File 'lib/codemodels/position.rb', line 147 def end_column @end_point.column end |
#end_line ⇒ Object
139 140 141 |
# File 'lib/codemodels/position.rb', line 139 def end_line @end_point.line end |
#eql?(other) ⇒ Boolean
115 116 117 118 119 |
# File 'lib/codemodels/position.rb', line 115 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_string(s) ⇒ Object
129 130 131 132 133 |
# File 'lib/codemodels/position.rb', line 129 def get_string(s) as = @begin_point.to_absolute_index(s) ae = @end_point.to_absolute_index(s) s[as..ae] end |
#include?(other) ⇒ Boolean
151 152 153 |
# File 'lib/codemodels/position.rb', line 151 def include?(other) (self.begin_point <= other.begin_point) && (self.end_point >= other.end_point) end |
#to_s ⇒ Object
125 126 127 |
# File 'lib/codemodels/position.rb', line 125 def to_s "from #{@begin_point} to #{@end_point}" end |