Module: Triplets

Included in:
URI::Git, URI::SCP, URI::SSH
Defined in:
lib/uri/triplets.rb

Overview

Triplets is a mix-in for subclasses of URI::Generic, which allows URI to use SCP-style Triplet URLs in a somewhat more meaningful way.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#schemeObject

Returns the value of attribute scheme.



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

def scheme
  @scheme
end

#userObject

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#to_sObject

rubocop:enable Metrics/AbcSize



39
40
41
42
43
# File 'lib/uri/triplets.rb', line 39

def to_s
  return triplet if triplet?

  rfc_uri
end

#triplet?Boolean

Use the same regular expressions that the parser uses to determine if this is a valid triplet.

Returns:

  • (Boolean)


47
48
49
50
51
52
# File 'lib/uri/triplets.rb', line 47

def triplet?
  # False if self matches a normal URI scheme
  rfc_uri !~ URI.parser.const_get(:SCHEME) &&
    # False unless self matches a Triplet scheme
    !!(triplet =~ URI.parser.const_get(:TRIPLET))
end