Class: Lookbook::PreviewExample
- Inherits:
-
Object
- Object
- Lookbook::PreviewExample
show all
- Includes:
- Taggable
- Defined in:
- lib/lookbook/preview_example.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Taggable
#code_object, #lookbook_display_params, #lookbook_group, #lookbook_hidden?, #lookbook_label, #lookbook_notes
Constructor Details
#initialize(name, preview) ⇒ PreviewExample
Returns a new instance of PreviewExample.
7
8
9
10
|
# File 'lib/lookbook/preview_example.rb', line 7
def initialize(name, preview)
@name = name
@preview = preview
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/lookbook/preview_example.rb', line 5
def name
@name
end
|
Instance Method Details
#display_params ⇒ Object
24
25
26
|
# File 'lib/lookbook/preview_example.rb', line 24
def display_params
@preview.display_params.merge(lookbook_display_params)
end
|
#hierarchy_depth ⇒ Object
58
59
60
|
# File 'lib/lookbook/preview_example.rb', line 58
def hierarchy_depth
@preview.lookbook_hierarchy_depth + 1
end
|
#id ⇒ Object
12
13
14
|
# File 'lib/lookbook/preview_example.rb', line 12
def id
path.underscore.tr("/", "-").tr("_", "-")
end
|
#label ⇒ Object
20
21
22
|
# File 'lib/lookbook/preview_example.rb', line 20
def label
lookbook_label.presence || name.titleize
end
|
#matchers ⇒ Object
54
55
56
|
# File 'lib/lookbook/preview_example.rb', line 54
def matchers
[@preview.label, label].map { |m| m.gsub(/\s/, "").downcase }
end
|
#method_source ⇒ Object
34
35
36
|
# File 'lib/lookbook/preview_example.rb', line 34
def method_source
code_object.source.split("\n")[1..-2].join("\n").strip_heredoc
end
|
#params ⇒ Object
28
29
30
31
32
|
# File 'lib/lookbook/preview_example.rb', line 28
def params
@params || code_object&.tags("param")&.map do |param|
Lookbook::Params.build_param(param, parameter_defaults[param.name])
end
end
|
#path ⇒ Object
16
17
18
|
# File 'lib/lookbook/preview_example.rb', line 16
def path
"#{@preview.lookbook_path}/#{name}"
end
|
#source_lang ⇒ Object
38
39
40
|
# File 'lib/lookbook/preview_example.rb', line 38
def source_lang
Lookbook::Lang.find(:ruby)
end
|
#template_lang(template_path) ⇒ Object
46
47
48
|
# File 'lib/lookbook/preview_example.rb', line 46
def template_lang(template_path)
Lookbook::Lang.guess(full_template_path(template_path)) || Lookbook::Lang.find(:html)
end
|
#template_source(template_path) ⇒ Object
42
43
44
|
# File 'lib/lookbook/preview_example.rb', line 42
def template_source(template_path)
File.read(full_template_path(template_path))
end
|
#type ⇒ Object
50
51
52
|
# File 'lib/lookbook/preview_example.rb', line 50
def type
:example
end
|