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



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

def path
  @path
end

#requestObject

Returns the value of attribute request

Returns:

  • (Object)

    the current value of request



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

def request
  @request
end

Instance Method Details

#hostObject



50
51
52
# File 'lib/usher/util/generate.rb', line 50

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

#portObject



54
55
56
# File 'lib/usher/util/generate.rb', line 54

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

#port_stringObject



58
59
60
# File 'lib/usher/util/generate.rb', line 58

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

#protocolObject



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

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

#schemeObject



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

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

#urlObject



62
63
64
65
66
# File 'lib/usher/util/generate.rb', line 62

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