Implments handling helpers for OCCI locations. These are especially useful for rendering and butter-passing purposes.
@attr uris [Set] collection of URIs representing locations
@author Boris Parak <parak@cesnet.cz>
Methods to be redirected to `uris`
Constructs an instance with given URIs. If `uris` are omitted, an empty set will be automatically provided.
@param args [Hash] arguments with Location information @option args [Set] :uris collection of URIs representing locations
# File lib/occi/core/locations.rb, line 26 def initialize(args = {}) pre_initialize(args) default_args! args @uris = args.fetch(:uris) post_initialize(args) end
Applies given `host` to all locations contained in the collection.
@param host [String] hostname for locations
# File lib/occi/core/locations.rb, line 38 def host=(host) each { |uri| uri.host = host } end
Applies given `port` to all locations contained in the collection.
@param port [String] port number
# File lib/occi/core/locations.rb, line 45 def port=(port) each { |uri| uri.port = port } end
Applies given `scheme` to all locations contained in the collection.
@param scheme [String] URI scheme
# File lib/occi/core/locations.rb, line 52 def scheme=(scheme) each { |uri| uri.scheme = scheme } end
Validates all locations in the collections and raises an error if there is an invalid location. During this process, all locations will be converted to `URI` instances.
@raise [Occi::Core::Errors::LocationValidationError] if some location is invalid
# File lib/occi/core/locations.rb, line 74 def valid! map! { |uri| return_or_convert uri } rescue => ex raise Occi::Core::Errors::LocationValidationError, ex.message end
Validates all locations contained in the collection. Validation errors are only logged.
@return [TrueClass] if locations are valid @return [FalseClass] if locations are invalid
# File lib/occi/core/locations.rb, line 61 def valid? valid! true rescue => ex logger.warn "Location invalid: #{ex.message}" false end