Class: Lookbook::PreviewGroup
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Entity
#<=>, #id, #label, #lookup_path, #name
Constructor Details
#initialize(name, examples, preview) ⇒ PreviewGroup
Returns a new instance of PreviewGroup.
7
8
9
10
11
12
|
# File 'lib/lookbook/entities/preview_group.rb', line 7
def initialize(name, examples, preview)
@name = Utils.name(name)
@examples = PreviewExampleCollection.new(examples)
@preview = preview
@lookup_path = "#{parent.lookup_path}/#{@name}"
end
|
Instance Attribute Details
#examples ⇒ Object
Returns the value of attribute examples.
5
6
7
|
# File 'lib/lookbook/entities/preview_group.rb', line 5
def examples
@examples
end
|
#preview ⇒ Object
Also known as:
parent
Returns the value of attribute preview.
5
6
7
|
# File 'lib/lookbook/entities/preview_group.rb', line 5
def preview
@preview
end
|
Instance Method Details
#components ⇒ Object
22
23
24
|
# File 'lib/lookbook/entities/preview_group.rb', line 22
def components
@_components ||= ComponentCollection.new(examples.flat_map(&:components).uniq(&:path))
end
|
#display_options ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/lookbook/entities/preview_group.rb', line 14
def display_options
merged = {}
examples.to_a.reverse.map do |example|
merged.merge!(example.display_options)
end
merged
end
|
#search_terms ⇒ Object
26
27
28
|
# File 'lib/lookbook/entities/preview_group.rb', line 26
def search_terms
[parent.label, label]
end
|
#tag(tag_name = nil) ⇒ Object
34
35
36
|
# File 'lib/lookbook/entities/preview_group.rb', line 34
def tag(tag_name = nil)
tags(tag_name).first
end
|
30
31
32
|
# File 'lib/lookbook/entities/preview_group.rb', line 30
def tags(tag_name = nil)
examples.flat_map { |example| example.tags(tag_name) }
end
|
#type ⇒ Object
42
43
44
|
# File 'lib/lookbook/entities/preview_group.rb', line 42
def type
:group
end
|
#url_path ⇒ Object
38
39
40
|
# File 'lib/lookbook/entities/preview_group.rb', line 38
def url_path
lookbook_inspect_path(path)
end
|