Class: DeadCodeTerminator::Cond::EnvIndex

Inherits:
Base
  • Object
show all
Defined in:
lib/dead_code_terminator/cond/env_index.rb

Overview

ENV s(:index,

s(:const, nil, :ENV),
s(:str, "PRODUCTION"))

Constant Summary

Constants inherited from Base

Base::ELSE, Base::THEN

Instance Attribute Summary

Attributes inherited from Base

#ast, #env

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from DeadCodeTerminator::Cond::Base

Instance Method Details

#valueObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/dead_code_terminator/cond/env_index.rb', line 10

def value
  return if ast.type != :index

  hash, key = ast.children
  return if hash != s(:const, nil, :ENV)

  return unless (matched_env_key = given_env_key(key))

  env[matched_env_key] ? THEN : ELSE
end