| Server IP : 157.230.181.24 / Your IP : 216.73.217.11 Web Server : Apache/2.4.58 (Ubuntu) System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64 User : ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/vhosts/convo/node_modules/bootstrap-sass/tasks/converter/ |
Upload File : |
# regular string scanner works with bytes
# this one works with chars and provides #scan_next
class Converter
class CharStringScanner
extend Forwardable
def initialize(*args)
@s = StringScanner.new(*args)
end
def_delegators :@s, :scan_until, :skip_until, :string
# advance scanner to pos after the next match of pattern and return the match
def scan_next(pattern)
return unless @s.scan_until(pattern)
@s.matched
end
def pos
byte_to_str_pos @s.pos
end
def pos=(i)
@s.pos = str_to_byte_pos i
i
end
private
def byte_to_str_pos(pos)
@s.string.byteslice(0, pos).length
end
def str_to_byte_pos(pos)
@s.string.slice(0, pos).bytesize
end
end
end