Class: URL

Inherits:
Object
  • Object
show all
Defined in:
lib/jiraSOAP/url.rb,
lib/macruby_stuff.rb

Overview

A bit of a hack to support using an NSURL in MacRuby while still supporting MRI by using the URI module.

I suggest not thinking about it too much beyond this point: this is a URI object if you are running on CRuby, but it will be an NSURL if you are running on MacRuby.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url_string) ⇒ URI::HTTP, NSURL

Initializes @url with the correct object type.

Parameters:

  • url (String)

    string to turn into some kind of URL object



14
15
16
# File 'lib/jiraSOAP/url.rb', line 14

def initialize(url)
  @url = URI.parse url
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

The magic of the hack, passing everything to the level beneath.



26
27
28
# File 'lib/jiraSOAP/url.rb', line 26

def method_missing(method, *args)
  @url.send method, *args
end

Instance Attribute Details

#urlNSURL, URI::HTTP

Returns the type depends on your RUBY_ENGINE.

Returns:

  • (NSURL, URI::HTTP)

    the type depends on your RUBY_ENGINE



9
10
11
# File 'lib/jiraSOAP/url.rb', line 9

def url
  @url
end

Instance Method Details

#to_sString

The to_s method technically exists and so method_missing would not work its magic to redirect it to @url so we manually override.

Returns:

  • (String)


21
22
23
# File 'lib/jiraSOAP/url.rb', line 21

def to_s
  @url.to_s
end