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_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
#hierarchy_depth ⇒ Object
48
49
50
|
# File 'lib/lookbook/preview_example.rb', line 48
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("_", "-")
end
|
#label ⇒ Object
20
21
22
|
# File 'lib/lookbook/preview_example.rb', line 20
def label
lookbook_label.presence || name.titleize
end
|
#matchers ⇒ Object
44
45
46
|
# File 'lib/lookbook/preview_example.rb', line 44
def matchers
[@preview.label, label].map { |m| m.gsub(/\s/, "").downcase }
end
|
#method_source ⇒ Object
24
25
26
|
# File 'lib/lookbook/preview_example.rb', line 24
def method_source
code_object.source.split("\n")[1..-2].join("\n").strip_heredoc
end
|
#path ⇒ Object
16
17
18
|
# File 'lib/lookbook/preview_example.rb', line 16
def path
"#{@preview.lookbook_path}/#{name}"
end
|
#source_lang ⇒ Object
28
29
30
|
# File 'lib/lookbook/preview_example.rb', line 28
def source_lang
Lookbook::Lang.find(:ruby)
end
|
#template_lang(template_path) ⇒ Object
36
37
38
|
# File 'lib/lookbook/preview_example.rb', line 36
def template_lang(template_path)
Lookbook::Lang.guess(full_template_path(template_path)) || Lookbook::Lang.find(:html)
end
|
#template_source(template_path) ⇒ Object
32
33
34
|
# File 'lib/lookbook/preview_example.rb', line 32
def template_source(template_path)
File.read(full_template_path(template_path))
end
|
#type ⇒ Object
40
41
42
|
# File 'lib/lookbook/preview_example.rb', line 40
def type
:example
end
|