Class: Packcr::Parser::Location
- Inherits:
-
Object
- Object
- Packcr::Parser::Location
- Defined in:
- lib/packcr/parser.rb
Instance Attribute Summary collapse
-
#charnum ⇒ Object
readonly
Returns the value of attribute charnum.
-
#linenum ⇒ Object
readonly
Returns the value of attribute linenum.
-
#linepos ⇒ Object
readonly
Returns the value of attribute linepos.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #forward(buffer, cur, n) ⇒ Object
- #forward!(buffer, cur, n) ⇒ Object
-
#initialize(charnum = 0, linenum = 0, linepos = 0) ⇒ Location
constructor
A new instance of Location.
Constructor Details
#initialize(charnum = 0, linenum = 0, linepos = 0) ⇒ Location
Returns a new instance of Location.
4064 4065 4066 4067 4068 |
# File 'lib/packcr/parser.rb', line 4064 def initialize(charnum = 0, linenum = 0, linepos = 0) @charnum = charnum @linenum = linenum @linepos = linepos end |
Instance Attribute Details
#charnum ⇒ Object (readonly)
Returns the value of attribute charnum.
4062 4063 4064 |
# File 'lib/packcr/parser.rb', line 4062 def charnum @charnum end |
#linenum ⇒ Object (readonly)
Returns the value of attribute linenum.
4062 4063 4064 |
# File 'lib/packcr/parser.rb', line 4062 def linenum @linenum end |
#linepos ⇒ Object (readonly)
Returns the value of attribute linepos.
4062 4063 4064 |
# File 'lib/packcr/parser.rb', line 4062 def linepos @linepos end |
Instance Method Details
#+(other) ⇒ Object
4070 4071 4072 |
# File 'lib/packcr/parser.rb', line 4070 def +(other) Location.new(other.charnum, other.linenum) end |
#-(other) ⇒ Object
4074 4075 4076 |
# File 'lib/packcr/parser.rb', line 4074 def -(other) Location.new(other.charnum, other.linenum) end |
#forward(buffer, cur, n) ⇒ Object
4078 4079 4080 |
# File 'lib/packcr/parser.rb', line 4078 def forward(buffer, cur, n) Location.new(@charnum, @linenum).forward!(buffer, cur, n) end |
#forward!(buffer, cur, n) ⇒ Object
4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 |
# File 'lib/packcr/parser.rb', line 4082 def forward!(buffer, cur, n) buffer[cur, n].scan(/(.*)(\n)?/) do if Regexp.last_match[2] @linenum += 1 @pos = 0 else @charnum += Regexp.last_match[1].length end end self end |