Class: Usher::Util::Generators::URL::UrlParts

Inherits:
Struct
  • Object
show all
Defined in:
lib/usher/util/generate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



25
26
27
# File 'lib/usher/util/generate.rb', line 25

def path
  @path
end

#requestObject

Returns the value of attribute request

Returns:

  • (Object)

    the current value of request



25
26
27
# File 'lib/usher/util/generate.rb', line 25

def request
  @request
end

Instance Method Details

#hostObject



34
35
36
# File 'lib/usher/util/generate.rb', line 34

def host
  @host ||= generate_with(:host) || request.host
end

#portObject



38
39
40
# File 'lib/usher/util/generate.rb', line 38

def port
  @port ||= generate_with(:port) || request.port
end

#port_stringObject



42
43
44
# File 'lib/usher/util/generate.rb', line 42

def port_string
  @port_string ||= standard_port? ? '' : ":#{port}"
end

#protocolObject



30
31
32
# File 'lib/usher/util/generate.rb', line 30

def protocol
  @protocol ||= scheme ? "#{scheme}://" : request.protocol
end

#schemeObject



26
27
28
# File 'lib/usher/util/generate.rb', line 26

def scheme
  @scheme ||= generate_with(:scheme) || (request.respond_to?(:scheme) and request.scheme)
end

#urlObject



46
47
48
49
50
# File 'lib/usher/util/generate.rb', line 46

def url            
  path.route.generate_with.nil? || path.route.generate_with.empty? ?
    request.url :
    protocol + host + port_string
end