Class: Xcodeproj::XCScheme::CommandLineArgument

Inherits:
XMLElementWrapper show all
Defined in:
lib/xcodeproj/scheme/command_line_arguments.rb

Overview

This class wraps the CommandLineArgument node of a .xcscheme XML file. Environment arguments are accessible via the NSDictionary returned from

[NSProcessInfo processInfo

arguments] in your app code.

Instance Attribute Summary

Attributes inherited from XMLElementWrapper

#xml_element

Instance Method Summary collapse

Methods inherited from XMLElementWrapper

#to_s

Constructor Details

#initialize(node_or_argument) ⇒ CommandLineArgument



112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/xcodeproj/scheme/command_line_arguments.rb', line 112

def initialize(node_or_argument)
  create_xml_element_with_fallback(node_or_argument, COMMAND_LINE_ARG_NODE) do
    raise "Must pass a Hash with 'argument' and 'enabled'!" unless node_or_argument.is_a?(Hash) &&
        node_or_argument.key?(:argument) && node_or_argument.key?(:enabled)

    @xml_element.attributes['argument'] = node_or_argument[:argument]
    @xml_element.attributes['isEnabled'] = if node_or_argument.key?(:enabled)
                                             bool_to_string(node_or_argument[:enabled])
                                           else
                                             bool_to_string(false)
                                           end
  end
end

Instance Method Details

#argumentString

Returns the CommandLineArgument’s key



129
130
131
# File 'lib/xcodeproj/scheme/command_line_arguments.rb', line 129

def argument
  @xml_element.attributes['argument']
end

#argument=(argument) ⇒ Object

Sets the CommandLineArgument’s key



136
137
138
# File 'lib/xcodeproj/scheme/command_line_arguments.rb', line 136

def argument=(argument)
  @xml_element.attributes['argument'] = argument
end

#enabledBool

Returns the CommandLineArgument’s enabled state



143
144
145
# File 'lib/xcodeproj/scheme/command_line_arguments.rb', line 143

def enabled
  string_to_bool(@xml_element.attributes['isEnabled'])
end

#enabled=(enabled) ⇒ Object

Sets the CommandLineArgument’s enabled state



150
151
152
# File 'lib/xcodeproj/scheme/command_line_arguments.rb', line 150

def enabled=(enabled)
  @xml_element.attributes['isEnabled'] = bool_to_string(enabled)
end

#to_hHash{:key => String, :value => String, :enabled => Bool}



157
158
159
# File 'lib/xcodeproj/scheme/command_line_arguments.rb', line 157

def to_h
  { :argument => argument, :enabled => enabled }
end