Class: Dry::View::Path
- Inherits:
-
Object
- Object
- Dry::View::Path
- Defined in:
- lib/dry/view/path.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #chdir(dirname) ⇒ Object
-
#initialize(dir, options = {}) ⇒ Path
constructor
A new instance of Path.
- #lookup(name, format) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(dir, options = {}) ⇒ Path
Returns a new instance of Path.
10 11 12 13 |
# File 'lib/dry/view/path.rb', line 10 def initialize(dir, = {}) @dir = Pathname(dir) @root = Pathname(.fetch(:root, dir)) end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
8 9 10 |
# File 'lib/dry/view/path.rb', line 8 def dir @dir end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/dry/view/path.rb', line 8 def root @root end |
Instance Method Details
#chdir(dirname) ⇒ Object
19 20 21 |
# File 'lib/dry/view/path.rb', line 19 def chdir(dirname) self.class.new(dir.join(dirname), root: root) end |
#lookup(name, format) ⇒ Object
15 16 17 |
# File 'lib/dry/view/path.rb', line 15 def lookup(name, format) template?(name, format) || template?("shared/#{name}", format) || !root? && chdir('..').lookup(name, format) end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/dry/view/path.rb', line 23 def to_s dir end |