Class: Seijaku::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/seijaku/variable.rb

Overview

variable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variable) ⇒ Variable

Returns a new instance of Variable.

Raises:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/seijaku/variable.rb', line 8

def initialize(variable)
  @key = variable.first

  value = variable.last
  @value = value

  return unless value.start_with?("$")

  env_key = value.split("$").last
  env_value = ENV.fetch(env_key, nil)

  raise VariableError, "no value set for #{env_key}", [] if env_value.nil?

  @value = env_value
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/seijaku/variable.rb', line 6

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/seijaku/variable.rb', line 6

def value
  @value
end