class AdLint::StringContent
DESCRIPTION¶ ↑
Object
represents the whole content of the string.
Public Class Methods
new(str, tab_width = 8, fpath = nil, line_no = 1, column_no = 1)
click to toggle source
DESCRIPTION¶ ↑
Constructs the content object of the string.
PARAMETER¶ ↑
- str
-
String
– Target string. - fpath
-
Pathname
– File path name contains the target string. - line_no
-
Integer
– Initial line-no of the target string.
# File lib/adlint/lexer.rb, line 84 def initialize(str, tab_width = 8, fpath = nil, line_no = 1, column_no = 1) @scanner = StringScanner.new(str) @tab_width = tab_width @fpath, @line_no, @column_no = fpath, line_no, column_no @appearance_column_no = column_no end
Public Instance Methods
_debug_inspect()
click to toggle source
# File lib/adlint/lexer.rb, line 139 def _debug_inspect @scanner.rest end
check(regexp)
click to toggle source
# File lib/adlint/lexer.rb, line 114 def check(regexp) @scanner.check(regexp) end
eat!(len = 1)
click to toggle source
empty?()
click to toggle source
location()
click to toggle source
# File lib/adlint/lexer.rb, line 91 def location Location.new(@fpath, @line_no, @column_no, @appearance_column_no) end
Private Instance Methods
update_location(tok)
click to toggle source
# File lib/adlint/lexer.rb, line 144 def update_location(tok) if (nl_cnt = tok.count("\n")) > 0 @line_no += nl_cnt lst_line = tok[tok.rindex("\n")..-1] @column_no = lst_line.length @appearance_column_no = lst_line.gsub(/\t/, " " * @tab_width).length else @column_no += tok.length @appearance_column_no += tok.gsub(/\t/, " " * @tab_width).length end forget_memo_of__location end