Class: Atlas::UrlBuilder
- Inherits:
-
Object
- Object
- Atlas::UrlBuilder
- Defined in:
- lib/atlas/url_builder.rb
Overview
A class which takes (and extends) Atlas tags and builds URLs from them.
This allows us to refer to items using the same identifiers as Vagrant, with a few extras.
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag) ⇒ UrlBuilder
constructor
A new instance of UrlBuilder.
Constructor Details
#initialize(tag) ⇒ UrlBuilder
Returns a new instance of UrlBuilder.
25 26 27 28 29 |
# File 'lib/atlas/url_builder.rb', line 25 def initialize(tag) user, box, version, provider = tag.split(%r{\/}) @tag = { user: user, box: box, version: version, provider: provider } end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
7 8 9 |
# File 'lib/atlas/url_builder.rb', line 7 def tag @tag end |
Class Method Details
.url_for(user = nil, box = nil, version = nil, provider = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/atlas/url_builder.rb', line 9 def self.url_for(user = nil, box = nil, version = nil, provider = nil) url = '' if user && !box return "/user/#{user}" else url << "/box/#{user}" end url << "/#{box}" if box url << "/version/#{version}" if version url << "/provider/#{provider}" if provider url end |