Class: URI::XGrowlResource

Inherits:
Generic
  • Object
show all
Defined in:
lib/uri/x_growl_resource.rb

Constant Summary collapse

DEFAULT_PORT =
nil
COMPONENT =
[ :scheme, :unique_id ]
UNIQUE_ID_REGEXP =
/\A[\w-]+\z/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ XGrowlResource

Returns a new instance of XGrowlResource.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/uri/x_growl_resource.rb', line 23

def initialize *args
  super

  @unique_id = nil

  if UNIQUE_ID_REGEXP =~ @host then
    if args[-1] then # arg_check
      self.unique_id = @host
    else
      set_unique_id @host
    end
  else
    raise URI::InvalidComponentError,
      "unrecognized opaque part for x-growl-resource URL: #{@host}"
  end
end

Instance Attribute Details

#unique_idObject

Returns the value of attribute unique_id.



9
10
11
# File 'lib/uri/x_growl_resource.rb', line 9

def unique_id
  @unique_id
end

Class Method Details

.build(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/uri/x_growl_resource.rb', line 11

def self.build args
  tmp = URI::Util.make_components_hash self, args

  if tmp[:unique_id] then
    tmp[:host] = tmp[:unique_id]
  else
    tmp[:host] = ''
  end

  super tmp
end

Instance Method Details

#to_sObject

:nodoc:



40
41
42
# File 'lib/uri/x_growl_resource.rb', line 40

def to_s # :nodoc:
  "#{@scheme}://#{@unique_id}"
end