Class: Build::URI::Triplet

Inherits:
Struct
  • Object
show all
Includes:
Base
Defined in:
lib/build/uri/triplet.rb

Constant Summary collapse

PARSER =
%r{\A
	(?:(?<userinfo>.+)@)?
	(?<host>[\w.-]+)
	:(?<path>.*)
\z}x.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#+, #basename, #dirname, #merge

Instance Attribute Details

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



23
24
25
# File 'lib/build/uri/triplet.rb', line 23

def host
  @host
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



23
24
25
# File 'lib/build/uri/triplet.rb', line 23

def path
  @path
end

#userinfoObject

Returns the value of attribute userinfo

Returns:

  • (Object)

    the current value of userinfo



23
24
25
# File 'lib/build/uri/triplet.rb', line 23

def userinfo
  @userinfo
end

Class Method Details

.parse(string) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/build/uri/triplet.rb', line 48

def self.parse(string)
	if match = PARSER.match(string)
		self.new(
			match[:userinfo],
			match[:host],
			match[:path],
		).freeze
	end
end

Instance Method Details

#local?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/build/uri/triplet.rb', line 32

def local?
	false
end

#to_sObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/build/uri/triplet.rb', line 36

def to_s
	buffer = String.new
	
	if userinfo
		buffer << userinfo << '@'
	end
	
	buffer << host << ':' << path
	
	return buffer
end