Sha256: dcd44527d7fddceb998583b7cbfcbe135c061c33cb32023f7f2139f79e88aabc
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module Translate OPERATOR = { :[] => :element_read, :[]= => :element_write, :** => :power, :~ => :not, :+@ => :unary_plus, :-@ => :unary_minus, :* => :product, :/ => :quotient, :% => :modulo, :+ => :plus, :- => :minus, :>> => :right_shift, :<< => :left_shift, :& => :and, :^ => :xor, :| => :or, :<= => :less_or_equal, :< => :less, :> => :greater, :>= => :greater_or_equal, :<=> => :comparison, :== => :eql, :=== => :case_comparison, :=~ => :match } def self.method_pre(method) method_with_suffix(method, :pre) end def self.method_post(method) method_with_suffix(method, :post) end def self.method_with_suffix(method, type) operator = OPERATOR[method] suffix = '_' + type.to_s if operator.nil? method_string = method.to_s length = method_string.length head = method_string[0...length-1] tail = method_string[length-1...length] if ['?', '!', '='].include?(tail) (head + suffix + tail).to_sym else (method_string + suffix).to_sym end else ('op_' + operator.to_s + suffix).to_sym end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
armin-joellenbeck-rdbc-0.0.4 | lib/translate.rb |
armin-joellenbeck-rdbc-0.0.5 | lib/translate.rb |