Module: EDNGRAMMAR::RAppStringB646

Defined in:
lib/parser/edngrammar.rb

Instance Method Summary collapse

Instance Method Details

#astObject



9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
# File 'lib/parser/edngrammar.rb', line 9938

def ast
  t = text_value.gsub(/\s|#[^\n]*(?:\n|\z)/, '').chars.each_slice(4).map(&:join)
  if last = t[-1]
    last << "=" * (4 - last.size)
  end
  b = t.join.tr("-_", "+/")
  begin
    b.unpack("m0")[0]
  rescue ArgumentError
    raise ArgumentError, "cbor-diagnostic: invalid base64 #{b.inspect}", caller[1..-1]
  end
end