Class: Snmp2mkr::ConfigTypes::EnvString

Inherits:
Base
  • Object
show all
Defined in:
lib/snmp2mkr/config_types/env_string.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#binded_context

Instance Method Summary collapse

Methods inherited from Base

#bind_context, #children, #collect_children, #evaluate, #initialize, #inspect

Constructor Details

This class inherits a constructor from Snmp2mkr::ConfigTypes::Base

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



17
18
19
# File 'lib/snmp2mkr/config_types/env_string.rb', line 17

def value
  @value
end

Instance Method Details

#setup(str_or_hash) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/snmp2mkr/config_types/env_string.rb', line 6

def setup(str_or_hash)
  @value = case str_or_hash
           when String
             str_or_hash
           when Hash
             ENV.fetch(str_or_hash.fetch('env'))
           else
             raise TypeError, "#{self.class} must be given a String or a Hash with key 'env'"
           end
end