Class: Jansson::FFI::Error Private
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- Jansson::FFI::Error
- Defined in:
- lib/jansson/ffi.rb,
lib/jansson/ffi/ext/error.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
Instance Method Details
#description(source_string) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jansson/ffi/ext/error.rb', line 6 def description(source_string) row = self[:line] col = self[:column] msg = self[:text].to_s source = source_string.each_line.to_a[row - 1].strip arrow = ' ' * (col - 1) + '^' if source.length > 40 if col >= 20 source = '... ' + source.slice(col - 20, 40) + ' ...' arrow = ' ' + arrow .slice(col - 20, 40) else source = source.slice(0, 40) + ' ...' arrow = arrow .slice(0, 40) end end "near line: #{row}, column: #{col}: #{msg}\n#{source}\n#{arrow}" end |