Class: Uri

Inherits:
Object
  • Object
show all
Defined in:
lib/regexpr-uri.rb

Defined Under Namespace

Classes: Flags

Constant Summary collapse

RegExpr =
::RegExpr[
	:scheme => '( "http" | "ftp" ) "s" ? | "sftp" | "fish"',
	:username => '[^:@]*',
	:password => '[^@]*',
	:host => 'hostname | ipv4',
	:port => 'digit +',
	:path => '( "/" ? [^?#]* "/" ) ?',
	:file => '[^/?#] *',
	:flags => '[^#] *',
	:fragment => '. *',
	'ipv4digits' => '0..255',
	'ipv6digits' => '[0-9a-bA-B] {1,4}',
	'userinfo' => 'username ( ":" password ) ?',
	'domainlabel' => 'alphadigit ( ( alphadigit | "-" ) * alphadigit ) ?',
	'hostname' => 'domainlabel ( "." | domainlabel ) *',
	'ipv4' => 'ipv4digits ( "." ipv4digits ) {3,3}',
	'request_uri' => '( path ? file ) ? ( "?" flags ) ?',
	'serv' => 'host ( ":" port ? ) ?',
	'pre' => '( ( scheme "://" ) ( auth "@" ) ? serv ) ?',
	'uri' => 'pre request_uri ( "#" fragment ) ?',
	'main' => 'uri'
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Uri

Returns a new instance of Uri.



23
# File 'lib/regexpr-uri.rb', line 23

def initialize( uri)  self. uri= uri  end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def file
  @file
end

#flagsObject

Returns the value of attribute flags.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def flags
  @flags
end

#fragmentObject

Returns the value of attribute fragment.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def fragment
  @fragment
end

#hostObject

Returns the value of attribute host.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def host
  @host
end

#passwordObject

Returns the value of attribute password.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def password
  @password
end

#pathObject

Returns the value of attribute path.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def path
  @path
end

#portObject

Returns the value of attribute port.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def port
  @port
end

#schemeObject

Returns the value of attribute scheme.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def scheme
  @scheme
end

#usernameObject

Returns the value of attribute username.



22
23
24
# File 'lib/regexpr-uri.rb', line 22

def username
  @username
end

Class Method Details

.new(uri) ⇒ Object



17
18
19
# File 'lib/regexpr-uri.rb', line 17

def new uri
	uri. instance_of?( Uri) ? uri. dup : super( uri)
end

Instance Method Details

#preObject



26
# File 'lib/regexpr-uri.rb', line 26

def pre() (self. scheme ? self. scheme+ '://' : '')+ self. serv end

#servObject



27
# File 'lib/regexpr-uri.rb', line 27

def serv() (self. host|| '')+ (self. port ? ':'+ self. port : '') end

#to_sObject



25
# File 'lib/regexpr-uri.rb', line 25

def uri() self. pre+ self. uri+ (self. fragment ? '#'+ self. fragment : '') end

#uriObject



24
# File 'lib/regexpr-uri.rb', line 24

def uri() self. pre+ self. uri+ (self. fragment ? '#'+ self. fragment : '') end