Class: FormattedURL::URLSourceResolver
- Inherits:
-
Object
- Object
- FormattedURL::URLSourceResolver
- Defined in:
- lib/formatted_url/url_source_resolver.rb
Overview
Finds URL source
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Working format.
-
#path ⇒ Object
The URL path.
Instance Method Summary collapse
-
#initialize(path, format = :default) ⇒ URLSourceResolver
constructor
Receives the
path
for URL andformat
to work with. -
#source ⇒ Object
Defines URL source.
-
#url ⇒ Object
Returns the final formatted URL.
Constructor Details
#initialize(path, format = :default) ⇒ URLSourceResolver
Receives the path
for URL and format
to work with
13 14 15 16 |
# File 'lib/formatted_url/url_source_resolver.rb', line 13 def initialize(path, format = :default) @path = path @format = format end |
Instance Attribute Details
#format ⇒ Object (readonly)
Working format
9 10 11 |
# File 'lib/formatted_url/url_source_resolver.rb', line 9 def format @format end |
#path ⇒ Object
The URL path
7 8 9 |
# File 'lib/formatted_url/url_source_resolver.rb', line 7 def path @path end |
Instance Method Details
#source ⇒ Object
Defines URL source
19 20 21 22 23 24 25 26 |
# File 'lib/formatted_url/url_source_resolver.rb', line 19 def source STRATEGIES.each_key do |key| if clean_url.include? key.to_s return key end end return :default end |
#url ⇒ Object
Returns the final formatted URL
29 30 31 |
# File 'lib/formatted_url/url_source_resolver.rb', line 29 def url STRATEGIES[source].url(path, format) end |