Class: Jekyll::Importmap::Mappable
- Inherits:
-
Object
- Object
- Jekyll::Importmap::Mappable
- Defined in:
- lib/jekyll-importmap/mappable.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#keyword_init ⇒ Object
readonly
Returns the value of attribute keyword_init.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#preload ⇒ Object
readonly
Returns the value of attribute preload.
Instance Method Summary collapse
- #absolute_root_path ⇒ Object
- #calculate_absolute_root_path ⇒ Object
-
#initialize(hash, resolver = Jekyll::Importmap::Resolver) ⇒ Mappable
constructor
A new instance of Mappable.
- #resolved_path ⇒ Object
Constructor Details
#initialize(hash, resolver = Jekyll::Importmap::Resolver) ⇒ Mappable
Returns a new instance of Mappable.
8 9 10 11 12 13 |
# File 'lib/jekyll-importmap/mappable.rb', line 8 def initialize(hash, resolver=Jekyll::Importmap::Resolver) @path = hash[:path] @preload = hash[:preload] @keyword_init = hash[:keyword_init] ||= true @resolver = resolver end |
Instance Attribute Details
#keyword_init ⇒ Object (readonly)
Returns the value of attribute keyword_init.
6 7 8 |
# File 'lib/jekyll-importmap/mappable.rb', line 6 def keyword_init @keyword_init end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/jekyll-importmap/mappable.rb', line 6 def path @path end |
#preload ⇒ Object (readonly)
Returns the value of attribute preload.
6 7 8 |
# File 'lib/jekyll-importmap/mappable.rb', line 6 def preload @preload end |
Instance Method Details
#absolute_root_path ⇒ Object
18 19 20 |
# File 'lib/jekyll-importmap/mappable.rb', line 18 def absolute_root_path @pathname ||= calculate_absolute_root_path end |
#calculate_absolute_root_path ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll-importmap/mappable.rb', line 21 def calculate_absolute_root_path pathname = Pathname.new(@dir || @path) if pathname.absolute? pathname else # this is where you can adjust whether we allow adding js # files anywhere or just in the /assets/js directory Pathname.new(Dir.pwd).join(pathname) end end |
#resolved_path ⇒ Object
15 16 17 |
# File 'lib/jekyll-importmap/mappable.rb', line 15 def resolved_path @resolver.path_to_asset(@path) end |