Class: Hanami::View::Path Private

Inherits:
Object show all
Defined in:
lib/hanami/view/path.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, root: dir) ⇒ Path

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Path.

Since:

  • 2.1.0



28
29
30
31
# File 'lib/hanami/view/path.rb', line 28

def initialize(dir, root: dir)
  @dir = Pathname(dir)
  @root = Pathname(root)
end

Instance Attribute Details

#dirObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



14
15
16
# File 'lib/hanami/view/path.rb', line 14

def dir
  @dir
end

#rootObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



14
15
16
# File 'lib/hanami/view/path.rb', line 14

def root
  @root
end

Class Method Details

.[](path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



18
19
20
21
22
23
24
# File 'lib/hanami/view/path.rb', line 18

def self.[](path)
  if path.is_a?(self)
    path
  else
    new(path)
  end
end

Instance Method Details

#chdir(dirname) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



44
45
46
# File 'lib/hanami/view/path.rb', line 44

def chdir(dirname)
  self.class.new(dir.join(dirname), root: root)
end

#lookup(prefix, name, format) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Searches for a template using a wildcard for the engine extension

Since:

  • 2.1.0



37
38
39
40
# File 'lib/hanami/view/path.rb', line 37

def lookup(prefix, name, format)
  glob = dir.join(prefix, "#{name}.#{format}.*")
  Dir[glob].first
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



50
51
52
# File 'lib/hanami/view/path.rb', line 50

def to_s
  dir.to_s
end