Class: Mumukit::Platform::Application
- Defined in:
- lib/mumukit/platform/application.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #domain ⇒ Object
-
#initialize(url) ⇒ Application
constructor
A new instance of Application.
- #organic_domain(organization) ⇒ Object
- #organic_url(organization) ⇒ Object
- #organic_url_for(organization, path) ⇒ Object
- #relative_path(path) ⇒ Object
- #uri ⇒ Object
- #url_for(path) ⇒ Object
Constructor Details
#initialize(url) ⇒ Application
Returns a new instance of Application.
4 5 6 |
# File 'lib/mumukit/platform/application.rb', line 4 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/mumukit/platform/application.rb', line 2 def url @url end |
Instance Method Details
#domain ⇒ Object
22 23 24 |
# File 'lib/mumukit/platform/application.rb', line 22 def domain uri.host end |
#organic_domain(organization) ⇒ Object
18 19 20 |
# File 'lib/mumukit/platform/application.rb', line 18 def organic_domain(organization) organic_uri(organization).host end |
#organic_url(organization) ⇒ Object
14 15 16 |
# File 'lib/mumukit/platform/application.rb', line 14 def organic_url(organization) organic_uri(organization).to_s end |
#organic_url_for(organization, path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mumukit/platform/application.rb', line 30 def organic_url_for(organization, path) uri = organic_uri(organization) # warning: this code is tightly # coupled to the fact that applications can only rebuild urls # in fragmented-mode if uri.fragment uri.to_s + relative_path(path) else uri.url_for(relative_path path) end end |
#relative_path(path) ⇒ Object
42 43 44 |
# File 'lib/mumukit/platform/application.rb', line 42 def relative_path(path) path.start_with?('/') ? path[1..-1] : path end |
#uri ⇒ Object
8 9 10 |
# File 'lib/mumukit/platform/application.rb', line 8 def uri URI(@url) end |
#url_for(path) ⇒ Object
26 27 28 |
# File 'lib/mumukit/platform/application.rb', line 26 def url_for(path) uri.url_for(path) if path end |