Class: OBIX::Types::URI

Inherits:
Type
  • Object
show all
Defined in:
lib/obix/types/uri.rb

Instance Method Summary collapse

Methods inherited from Type

#initialize

Constructor Details

This class inherits a constructor from OBIX::Types::Type

Instance Method Details

#cast(value) ⇒ Object

Cast the given value to a URI.

value - Any object that responds to ‘to_s`.

Returns a string.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/obix/types/uri.rb', line 13

def cast value
  parent = @element.parent

  if parent
    url = ::URI.join parent.href, value
  else
    url = ::URI.join "#{OBIX.configuration.scheme}://#{OBIX.configuration.host}", value
  end

  url.to_s
end