Sha256: 98c3a057c3eebe290baeb580c351ab72c13f6d1819156c112b97b2db948a1cf0
Contents?: true
Size: 1005 Bytes
Versions: 26
Compression:
Stored size: 1005 Bytes
Contents
module Kernel OPERATORS = %w{ +@ -@ + - ** * / % ~ <=> << >> < > === == =~ <= >= | & ^ []= [] } OPERATORS_REGEXP = Regexp.new( '(' << OPERATORS.collect{ |k| Regexp.escape(k) }.join('|') << ')' ) OPERATORS_ESC_TABLE = { "+@" => "op_plus_self", "-@" => "op_minus_self", "+" => "op_plus", "-" => "op_minus", "**" => "op_pow", "*" => "op_mul", "/" => "op_div", "%" => "op_mod", "~" => "op_tilde", "<=>" => "op_cmp", "<<" => "op_lshift", ">>" => "op_rshift", "<" => "op_lt", ">" => "op_gt", "===" => "op_case_eq", "==" => "op_equal", "=~" => "op_apply", "<=" => "op_lt_eq", ">=" => "op_gt_eq", "|" => "op_or", "&" => "op_and", "^" => "op_xor", "[]=" => "op_store", "[]" => "op_fetch" } def op_esc( str ) str.gsub(OPERATORS_REGEXP){ OPERATORS_ESC_TABLE[$1] } end end
Version data entries
26 entries across 26 versions & 1 rubygems