Class: Lookbook::PreviewGroup
- Inherits:
-
Entity
- Object
- Entity
- Lookbook::PreviewGroup
show all
- Defined in:
- lib/lookbook/preview_group.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
#id, #path
Constructor Details
#initialize(name, preview, examples) ⇒ PreviewGroup
Returns a new instance of PreviewGroup.
5
6
7
8
9
10
|
# File 'lib/lookbook/preview_group.rb', line 5
def initialize(name, preview, examples)
@name = name
@preview = preview
@examples = examples
super("#{@preview.path}/#{name}")
end
|
Instance Attribute Details
#examples ⇒ Object
Returns the value of attribute examples.
3
4
5
|
# File 'lib/lookbook/preview_group.rb', line 3
def examples
@examples
end
|
#name ⇒ Object
Returns the value of attribute name.
3
4
5
|
# File 'lib/lookbook/preview_group.rb', line 3
def name
@name
end
|
#preview ⇒ Object
Returns the value of attribute preview.
3
4
5
|
# File 'lib/lookbook/preview_group.rb', line 3
def preview
@preview
end
|
Instance Method Details
#display_options ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/lookbook/preview_group.rb', line 24
def display_options
merged = {}
examples.reverse.map do |example|
merged.merge! example.display_options
end
merged
end
|
#hidden? ⇒ Boolean
32
33
34
|
# File 'lib/lookbook/preview_group.rb', line 32
def hidden?
false
end
|
#hierarchy_depth ⇒ Object
44
45
46
|
# File 'lib/lookbook/preview_group.rb', line 44
def hierarchy_depth
@preview.hierarchy_depth + 1
end
|
#label ⇒ Object
16
17
18
|
# File 'lib/lookbook/preview_group.rb', line 16
def label
name.titleize
end
|
#matchers ⇒ Object
40
41
42
|
# File 'lib/lookbook/preview_group.rb', line 40
def matchers
normalize_matchers(@preview.label, label)
end
|
#position ⇒ Object
36
37
38
|
# File 'lib/lookbook/preview_group.rb', line 36
def position
10000
end
|
#tag(name = nil) ⇒ Object
52
53
54
|
# File 'lib/lookbook/preview_group.rb', line 52
def tag(name = nil)
tags(name).first
end
|
48
49
50
|
# File 'lib/lookbook/preview_group.rb', line 48
def tags(name = nil)
examples.map { |example| example.tags(name) }.flatten
end
|
#type ⇒ Object
20
21
22
|
# File 'lib/lookbook/preview_group.rb', line 20
def type
:group
end
|
#url_path ⇒ Object
12
13
14
|
# File 'lib/lookbook/preview_group.rb', line 12
def url_path
lookbook_inspect_path lookup_path
end
|