Class: Gluey::Environment
- Inherits:
-
Object
- Object
- Gluey::Environment
- Defined in:
- lib/gluey/base/environment.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#mark_versions ⇒ Object
Returns the value of attribute mark_versions.
-
#path_prefix ⇒ Object
readonly
Returns the value of attribute path_prefix.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #[](material, path, mark = nil) ⇒ Object (also: #find_asset_file)
- #asset_url(material, path) ⇒ Object
-
#initialize(**opts, &block) ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize(**opts, &block) ⇒ Environment
Returns a new instance of Environment.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gluey/base/environment.rb', line 8 def initialize(**opts, &block) opts = { base_url: nil, path_prefix: '/assets' }.merge! opts opts.each do |k, value| next unless k.is_a? Symbol instance_variable_set "@#{k}", value end instance_exec &block if block root || raise('Root directory not defined!') end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/gluey/base/environment.rb', line 5 def base_url @base_url end |
#mark_versions ⇒ Object
Returns the value of attribute mark_versions.
6 7 8 |
# File 'lib/gluey/base/environment.rb', line 6 def mark_versions @mark_versions end |
#path_prefix ⇒ Object (readonly)
Returns the value of attribute path_prefix.
5 6 7 |
# File 'lib/gluey/base/environment.rb', line 5 def path_prefix @path_prefix end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
5 6 7 |
# File 'lib/gluey/base/environment.rb', line 5 def root @root end |
Instance Method Details
#[](material, path, mark = nil) ⇒ Object Also known as: find_asset_file
27 28 29 |
# File 'lib/gluey/base/environment.rb', line 27 def [](material, path, mark=nil) fetch(material, path, mark)[0] end |
#asset_url(material, path) ⇒ Object
23 24 25 |
# File 'lib/gluey/base/environment.rb', line 23 def asset_url(material, path) "#{base_url}#{path_prefix}/#{material}/#{real_path material, path}" end |