Class: Lookbook::Entity
- Inherits:
-
Object
show all
- Includes:
- Comparable
- Defined in:
- lib/lookbook/entities/entity.rb
Instance Method Summary
collapse
Constructor Details
#initialize(lookup_path = nil) ⇒ Entity
Returns a new instance of Entity.
6
7
8
|
# File 'lib/lookbook/entities/entity.rb', line 6
def initialize(lookup_path = nil)
@lookup_path = lookup_path
end
|
Instance Method Details
#<=>(other) ⇒ Object
40
41
42
|
# File 'lib/lookbook/entities/entity.rb', line 40
def <=>(other)
label <=> other.label
end
|
#id ⇒ Object
10
11
12
|
# File 'lib/lookbook/entities/entity.rb', line 10
def id
Utils.id(fetch_config(:id) { lookup_path.tr("/", "-") })
end
|
#label ⇒ Object
18
19
20
|
# File 'lib/lookbook/entities/entity.rb', line 18
def label
@_label ||= fetch_config(:label) { name.titleize }
end
|
#lookup_path ⇒ Object
Also known as:
path, logical_path
22
23
24
25
26
27
28
29
30
|
# File 'lib/lookbook/entities/entity.rb', line 22
def lookup_path
return @_lookup_path if @_lookup_path
directory = fetch_config(:logical_path) do
dir = File.dirname(@lookup_path)
dir if !dir.start_with?(".")
end
@_lookup_path ||= PathUtils.strip_slashes(PathUtils.to_path(directory, name))
end
|
#name ⇒ Object
14
15
16
|
# File 'lib/lookbook/entities/entity.rb', line 14
def name
@_name ||= Utils.name(File.basename(@lookup_path))
end
|
#type ⇒ Object
36
37
38
|
# File 'lib/lookbook/entities/entity.rb', line 36
def type
@_type ||= self.class.name.demodulize.underscore.downcase.to_sym
end
|
#url_path ⇒ Object
32
33
34
|
# File 'lib/lookbook/entities/entity.rb', line 32
def url_path
nil
end
|