Class: Sass::Source::Position
- Inherits:
-
Object
- Object
- Sass::Source::Position
- Defined in:
- .ruby-sass/lib/sass/source/position.rb
Instance Attribute Summary (collapse)
-
#line ⇒ Integer
The one-based line of the document associated with the position.
-
#offset ⇒ Integer
The one-based offset in the line of the document associated with the position.
Instance Method Summary (collapse)
-
#after(str) ⇒ Position
The source position after proceeding forward through `str`.
-
#initialize(line, offset) ⇒ Position
constructor
A new instance of Position.
-
#inspect ⇒ String
A string representation of the source position.
Constructor Details
#initialize(line, offset) ⇒ Position
Returns a new instance of Position
16 17 18 19 |
# File '.ruby-sass/lib/sass/source/position.rb', line 16 def initialize(line, offset) @line = line @offset = offset end |
Constructor Details
#initialize(line, offset) ⇒ Position
Returns a new instance of Position
16 17 18 19 |
# File '.ruby-sass/lib/sass/source/position.rb', line 16 def initialize(line, offset) @line = line @offset = offset end |
Instance Attribute Details
#line ⇒ Integer
The one-based line of the document associated with the position.
6 7 8 |
# File '.ruby-sass/lib/sass/source/position.rb', line 6 def line @line end |
#offset ⇒ Integer
The one-based offset in the line of the document associated with the position.
12 13 14 |
# File '.ruby-sass/lib/sass/source/position.rb', line 12 def offset @offset end |
Instance Method Details
#after(str) ⇒ Position
Returns The source position after proceeding forward through `str`.
29 30 31 32 33 34 35 36 37 |
# File '.ruby-sass/lib/sass/source/position.rb', line 29 def after(str) newlines = str.count("\n") Position.new(line + newlines, if newlines == 0 offset + str.length else str.length - str.rindex("\n") - 1 end) end |
#inspect ⇒ String
Returns A string representation of the source position.
22 23 24 |
# File '.ruby-sass/lib/sass/source/position.rb', line 22 def inspect "#{line.inspect}:#{offset.inspect}" end |