Class: Lookbook::Component

Inherits:
Entity
  • Object
show all
Defined in:
lib/lookbook/component.rb

Constant Summary

Constants included from Utils

Utils::FRONTMATTER_REGEX, Utils::POSITION_PREFIX_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#hidden?, #hierarchy_depth, #id, #label, #lookup_path, #matchers, #position, #type

Constructor Details

#initialize(name) ⇒ Component

Returns a new instance of Component.



5
6
7
8
# File 'lib/lookbook/component.rb', line 5

def initialize(name)
  @name = name
  super(path)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/lookbook/component.rb', line 3

def name
  @name
end

Instance Method Details

#dir_pathObject



22
23
24
# File 'lib/lookbook/component.rb', line 22

def dir_path
  full_path.dirname
end

#full_pathObject



18
19
20
# File 'lib/lookbook/component.rb', line 18

def full_path
  Pathname.new("#{Lookbook.config.components_path}/#{path}.rb")
end

#inline?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/lookbook/component.rb', line 30

def inline?
  template_path.present?
end

#pathObject



10
11
12
# File 'lib/lookbook/component.rb', line 10

def path
  name.underscore
end

#rel_pathObject



14
15
16
# File 'lib/lookbook/component.rb', line 14

def rel_path
  Pathname.new("#{path}.rb")
end

#template_pathObject



26
27
28
# File 'lib/lookbook/component.rb', line 26

def template_path
  Dir.glob("#{Lookbook.config.components_path}/#{path}.*.erb").first
end