class Xcodeproj::XCScheme::EnvironmentVariable
This class wraps the EnvironmentVariable
node of a .xcscheme XML file. Environment variables are accessible via the NSDictionary returned from
- [NSProcessInfo processInfo
-
environment] in your app code.
Public Class Methods
new(node_or_variable)
click to toggle source
@param [nil,REXML::Element,Hash{Symbol => String,Bool}] node_or_variable
- If nil, it will create a default XML node to use - If a REXML::Element, should be a <EnvironmentVariable> XML node to wrap - If a Hash, must contain keys :key and :value (Strings) and optionally :enabled (Boolean)
# File lib/xcodeproj/scheme/environment_variables.rb, line 104 def initialize(node_or_variable) create_xml_element_with_fallback(node_or_variable, VARIABLE_NODE) do raise "Must pass a Hash with 'key' and 'value'!" unless node_or_variable.is_a?(Hash) && node_or_variable.key?(:key) && node_or_variable.key?(:value) @xml_element.attributes['key'] = node_or_variable[:key] @xml_element.attributes['value'] = node_or_variable[:value] @xml_element.attributes['isEnabled'] = if node_or_variable.key?(:enabled) bool_to_string(node_or_variable[:enabled]) else bool_to_string(true) end end end
Public Instance Methods
enabled()
click to toggle source
Returns the EnvironmentValue’s enabled state @return [Bool]
# File lib/xcodeproj/scheme/environment_variables.rb, line 151 def enabled string_to_bool(@xml_element.attributes['isEnabled']) end
enabled=(enabled)
click to toggle source
Sets the EnvironmentValue’s enabled state @param [Bool] enabled
# File lib/xcodeproj/scheme/environment_variables.rb, line 158 def enabled=(enabled) @xml_element.attributes['isEnabled'] = bool_to_string(enabled) end
key()
click to toggle source
Returns the EnvironmentValue’s key @return [String]
# File lib/xcodeproj/scheme/environment_variables.rb, line 123 def key @xml_element.attributes['key'] end
key=(key)
click to toggle source
Sets the EnvironmentValue’s key @param [String] key
# File lib/xcodeproj/scheme/environment_variables.rb, line 130 def key=(key) @xml_element.attributes['key'] = key end
to_h()
click to toggle source
@return [Hash{:key => String, :value => String, :enabled => Bool}]
The environment variable XML node with attributes converted to a representative Hash
# File lib/xcodeproj/scheme/environment_variables.rb, line 165 def to_h { :key => key, :value => value, :enabled => enabled } end
value()
click to toggle source
Returns the EnvironmentValue’s value @return [String]
# File lib/xcodeproj/scheme/environment_variables.rb, line 137 def value @xml_element.attributes['value'] end
value=(value)
click to toggle source
Sets the EnvironmentValue’s value @param [String] value
# File lib/xcodeproj/scheme/environment_variables.rb, line 144 def value=(value) @xml_element.attributes['value'] = value end