Class: ExercismConfig::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/exercism_config/environment.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw_env) ⇒ Environment

Returns a new instance of Environment.



6
7
8
9
10
11
12
# File 'lib/exercism_config/environment.rb', line 6

def initialize(raw_env)
  @env = raw_env.to_s

  unless ALLOWED_ENVS.include?(env)
    raise Exercism::ConfigError, "environment must be one of development, test or production. Got #{env}."
  end
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/exercism_config/environment.rb', line 14

def ==(other)
  env == other.to_s
end

#development?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/exercism_config/environment.rb', line 34

def development?
  env == "development"
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/exercism_config/environment.rb', line 18

def eql?(other)
  env == other.to_s
end

#hashObject



22
23
24
# File 'lib/exercism_config/environment.rb', line 22

def hash
  env.hash
end

#inspectObject



30
31
32
# File 'lib/exercism_config/environment.rb', line 30

def inspect
  env
end

#production?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/exercism_config/environment.rb', line 42

def production?
  env == "production"
end

#test?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/exercism_config/environment.rb', line 38

def test?
  env == "test"
end

#to_sObject



26
27
28
# File 'lib/exercism_config/environment.rb', line 26

def to_s
  env
end