Sha256: 799889d98023e428eca09561785b6ef17bf1a407421c7184144d6704bd7a382d
Contents?: true
Size: 895 Bytes
Versions: 1
Compression:
Stored size: 895 Bytes
Contents
module Ruby2JS class Converter # (and # (...) # (...)) # (or # (...) # (...)) # (not # (...)) handle :and, :or, :not do |left, right=nil| type = @ast.type op_index = operator_index type lgroup = LOGICAL.include?( left.type ) && op_index < operator_index( left.type ) lgroup = true if left and left.type == :begin left = parse left left = "(#{ left })" if lgroup if right rgroup = LOGICAL.include?( right.type ) && op_index < operator_index( right.type ) rgroup = true if right.type == :begin right = parse right right = "(#{ right })" if rgroup end case type when :and "#{ left } && #{ right }" when :or "#{ left } || #{ right }" else "!#{ left }" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby2js-1.3.0 | lib/ruby2js/converter/logical.rb |