class DeadCodeTerminator::Cond::EnvIndex
s(:send,
s(:const, nil, :ENV), :[], s(:str, "FLAG"))
Public Instance Methods
given_env_key(ast)
click to toggle source
# File lib/dead_code_terminator/cond/env_index.rb, line 28 def given_env_key(ast) env.keys.detect { |key| ast == s(:str, key) } end
value()
click to toggle source
# File lib/dead_code_terminator/cond/env_index.rb, line 11 def value return if ast.type != :send hash, bracket_meth, *args = ast.children return if hash != s(:const, nil, :ENV) return if bracket_meth != :[] return if args.size != 1 key = args[0] return unless (matched_env_key = given_env_key(key)) env[matched_env_key] ? THEN : ELSE end