byte_offset(line, column) -> IntegerRuby 3.4 から[permalink][rdoc][edit]-
行番号と桁位置からバイトオフセットを求めます。
- [PARAM]
line: - 行番号(1 origin)
- [PARAM]
column: - 行頭からのバイト単位の桁位置(0 origin)
require "prism" source = Prism.parse("foo = 1\nbar = 2\n").source p source.byte_offset(2, 1) # => 9 p source.line(9) # => 2 - [PARAM]