Class: Lookbook::Entity

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/lookbook/entity.rb

Direct Known Subclasses

Collection, Component, Page, PreviewExample, PreviewGroup

Constant Summary

Constants included from Utils

Utils::FRONTMATTER_REGEX, Utils::POSITION_PREFIX_REGEX

Instance Method Summary collapse

Constructor Details

#initialize(reference_path) ⇒ Entity

Returns a new instance of Entity.



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

def initialize(reference_path)
  @refpath = reference_path
end

Instance Method Details

#hidden?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/lookbook/entity.rb', line 37

def hidden?
  false
end

#hierarchy_depthObject



29
30
31
# File 'lib/lookbook/entity.rb', line 29

def hierarchy_depth
  @refpath.present? ? @refpath.split("/").size : 0
end

#idObject



9
10
11
# File 'lib/lookbook/entity.rb', line 9

def id
  generate_id(lookup_path)
end

#labelObject



13
14
15
# File 'lib/lookbook/entity.rb', line 13

def label
  lookup_path.split("/").last.titleize
end

#lookup_pathObject Also known as: url_path



25
26
27
# File 'lib/lookbook/entity.rb', line 25

def lookup_path
  @lookup_path ||= to_lookup_path(@refpath)
end

#matchersObject



41
42
43
# File 'lib/lookbook/entity.rb', line 41

def matchers
  nil
end

#pathObject



21
22
23
# File 'lib/lookbook/entity.rb', line 21

def path
  @refpath
end

#positionObject



33
34
35
# File 'lib/lookbook/entity.rb', line 33

def position
  0
end

#typeObject



17
18
19
# File 'lib/lookbook/entity.rb', line 17

def type
  :item
end