Class: RubyScriptProvider::URL
- Inherits:
-
Object
- Object
- RubyScriptProvider::URL
- Defined in:
- lib/rubyscriptprovider.rb
Overview
Macro URL.
Constant Summary collapse
- EXPAND_PROTOCOL =
"vnd.sun.star.expand:"
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#url ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #absolutize ⇒ Object
- #basename(ext = "") ⇒ Object
- #create(url) ⇒ Object
- #dirname ⇒ Object
- #expand(uri) ⇒ Object
- #helper ⇒ Object
-
#initialize(ctx, context, url) ⇒ URL
constructor
A new instance of URL.
- #join(a, b = nil) ⇒ Object
- #to_uri(function_name = nil) ⇒ Object
- #to_url(uri) ⇒ Object
- #transient? ⇒ Boolean
Constructor Details
#initialize(ctx, context, url) ⇒ URL
Returns a new instance of URL.
172 173 174 175 176 177 |
# File 'lib/rubyscriptprovider.rb', line 172 def initialize(ctx, context, url) @ctx = ctx @context = context @url = url @url = helper.getRootStorageURI unless url end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
179 180 181 |
# File 'lib/rubyscriptprovider.rb', line 179 def context @context end |
#url ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute url.
179 180 181 |
# File 'lib/rubyscriptprovider.rb', line 179 def url @url end |
Instance Method Details
#absolutize ⇒ Object
191 192 193 194 |
# File 'lib/rubyscriptprovider.rb', line 191 def absolutize return Uno.absolutize(@url, @url) rescue nil return @url end |
#basename(ext = "") ⇒ Object
200 201 202 |
# File 'lib/rubyscriptprovider.rb', line 200 def basename(ext="") return File.basename(@url, ext) end |
#create(url) ⇒ Object
182 183 184 |
# File 'lib/rubyscriptprovider.rb', line 182 def create(url) return RubyScriptProvider::URL.new(@ctx, @context, url) end |
#dirname ⇒ Object
204 205 206 |
# File 'lib/rubyscriptprovider.rb', line 204 def dirname return File.dirname(@url) end |
#expand(uri) ⇒ Object
224 225 226 227 228 229 230 231 |
# File 'lib/rubyscriptprovider.rb', line 224 def (uri) url = @ctx.getValueByName( "/singletons/com.sun.star.util.theMacroExpander").(uri) url[EXPAND_PROTOCOL] = "" url = Uno.absolutize(url, url) rescue nil url += "/" if uri.end_with?("/") return url end |
#helper ⇒ Object
186 187 188 189 |
# File 'lib/rubyscriptprovider.rb', line 186 def helper return create_service("com.sun.star.script.provider.ScriptURIHelper", [LANGUAGE, @context]) end |
#join(a, b = nil) ⇒ Object
214 215 216 217 218 219 220 221 222 |
# File 'lib/rubyscriptprovider.rb', line 214 def join(a, b=nil) if b return a + b if a.end_with?("/") return "#{a}/#{b}" else return @url + a if @url.end_with?("/") return "#{@url}/#{a}" end end |
#to_uri(function_name = nil) ⇒ Object
208 209 210 211 212 |
# File 'lib/rubyscriptprovider.rb', line 208 def to_uri(function_name=nil) url = @url url += "$" + function_name if function_name return helper.getScriptURI(url) end |
#to_url(uri) ⇒ Object
233 234 235 236 237 |
# File 'lib/rubyscriptprovider.rb', line 233 def to_url(uri) url = helper.getStorageURI(uri) n = url.rindex("$") return url[0..n-1], url[n+1..-1] end |
#transient? ⇒ Boolean
196 197 198 |
# File 'lib/rubyscriptprovider.rb', line 196 def transient? return @url.start_with?(DOC_PROTOCOL) end |