Class: MacTypes::FileURL

Inherits:
FileBase show all
Defined in:
lib/_aem/mactypes.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileBase

#==, _coerce, #hash

Constructor Details

#initialize(path, desc) ⇒ FileURL

Returns a new instance of FileURL.



130
131
132
133
# File 'lib/_aem/mactypes.rb', line 130

def initialize(path, desc)
  @path = path
  @desc = desc
end

Class Method Details

.desc(desc) ⇒ Object



152
153
154
155
# File 'lib/_aem/mactypes.rb', line 152

def FileURL.desc(desc)
  # Make FileURL object from AEDesc of typeFSS, typeFSRef, typeFileURL. Note: descriptor type is not checked; clients are responsible for passing the correct type as other types will cause unexpected problems/errors.
  return new(nil, desc)
end

.hfs_path(path) ⇒ Object



142
143
144
145
# File 'lib/_aem/mactypes.rb', line 142

def FileURL.hfs_path(path)
  # Make FileURL object from HFS path.
  return new(AE.convert_url_to_path(AE.convert_path_to_url(path, KCFURLHFSPathStyle), KCFURLPOSIXPathStyle), nil)
end

.path(path) ⇒ Object

Constructors



137
138
139
140
# File 'lib/_aem/mactypes.rb', line 137

def FileURL.path(path)
  # Make FileURL object from POSIX path.
  return new(path, nil)
end

.url(url) ⇒ Object



147
148
149
150
# File 'lib/_aem/mactypes.rb', line 147

def FileURL.url(url)
  # Make FileURL object from file URL. Note: only the path portion of the URL is used; the domain will always be localhost.
  return FileURL.path(AE.convert_url_to_path(url, KCFURLPOSIXPathStyle))
end

Instance Method Details

#descObject

Methods



159
160
161
162
163
164
165
# File 'lib/_aem/mactypes.rb', line 159

def desc
  # Get as AEDesc. If constructed from Ruby, descriptor's type is always typeFileURL; if returned by aem, its type may be typeFSS, typeFSRef or typeFileURL.
  if not @desc
    @desc = AE::AEDesc.new(KAE::TypeFileURL, AE.convert_path_to_url(@path, KCFURLPOSIXPathStyle))
  end
  return @desc
end

#hfs_pathObject



180
181
182
# File 'lib/_aem/mactypes.rb', line 180

def hfs_path
  return AE.convert_url_to_path(AE.convert_path_to_url(path, KCFURLPOSIXPathStyle), KCFURLHFSPathStyle)
end

#inspectObject



186
187
188
# File 'lib/_aem/mactypes.rb', line 186

def inspect
  return "MacTypes::FileURL.path(#{to_s.inspect})"
end

#pathObject Also known as: to_s



172
173
174
175
176
177
178
# File 'lib/_aem/mactypes.rb', line 172

def path
  # Get as POSIX path.
  if not @path
    @path = AE.convert_url_to_path(FileBase._coerce(@desc, KAE::TypeFileURL).data, KCFURLPOSIXPathStyle)
  end
  return @path
end

#to_aliasObject



190
191
192
193
# File 'lib/_aem/mactypes.rb', line 190

def to_alias
  # Get as MacTypes::Alias.
  return MacTypes::Alias.desc(FileBase._coerce(desc, KAE::TypeAlias, to_s))
end

#to_file_urlObject



195
196
197
198
# File 'lib/_aem/mactypes.rb', line 195

def to_file_url
  # Get as MacTypes::FileURL; note that the resulting FileURL object will always pack as an AEDesc of typeFileURL.
  return MacTypes::FileURL.desc(FileBase._coerce(desc, KAE::TypeFileURL, to_s))
end

#urlObject



167
168
169
170
# File 'lib/_aem/mactypes.rb', line 167

def url
  # Get as URL string.
  return desc.coerce(KAE::TypeFileURL).data
end