class Xcodeproj::Workspace::FileReference
Describes a file reference of a Workspace
.
Attributes
path[R]
@return [String] the path to the project
Public Class Methods
from_node(xml_node)
click to toggle source
Returns a file reference given XML representation.
@param [REXML::Element] xml_node
the XML representation.
@return [FileReference] The new file reference instance.
# File lib/xcodeproj/workspace/file_reference.rb, line 40 def self.from_node(xml_node) type, path = xml_node.attribute('location').value.split(':', 2) if type == 'group' path = prepend_parent_path(xml_node, path) end new(path, type) end
new(path, type = 'group')
click to toggle source
@param [#to_s] path @see path @param [#to_s] type @see type
# File lib/xcodeproj/workspace/file_reference.rb, line 15 def initialize(path, type = 'group') @path = Pathname.new(path.to_s).cleanpath.to_s @type = type.to_s end
Public Instance Methods
==(other)
click to toggle source
@return [Bool] Wether a file reference is equal to another.
# File lib/xcodeproj/workspace/file_reference.rb, line 22 def ==(other) path == other.path && type == other.type end
Also aliased as: eql?
absolute_path(workspace_dir_path)
click to toggle source
Returns the absolute path of a file reference given the path of the directory containing workspace.
@param [#to_s] workspace_dir_path
The Path of the directory containing the workspace.
@return [String] The absolute path to the project.
# File lib/xcodeproj/workspace/file_reference.rb, line 64 def absolute_path(workspace_dir_path) workspace_dir_path = workspace_dir_path.to_s case type when 'group', 'container', 'self' File.expand_path(File.join(workspace_dir_path, path)) when 'absolute' File.expand_path(path) when 'developer' raise "Developer workspace file reference type is not yet supported (#{path})" else raise "Unsupported workspace file reference type `#{type}`" end end
hash()
click to toggle source
@return [Fixnum] A hash identical for equals objects.
# File lib/xcodeproj/workspace/file_reference.rb, line 29 def hash [path, type].hash end
to_node()
click to toggle source
@return [REXML::Element] the XML representation of the file reference.
# File lib/xcodeproj/workspace/file_reference.rb, line 50 def to_node REXML::Element.new('FileRef').tap do |element| element.add_attribute('location', "#{type}:#{path}") end end