Class: Adva::Static::Import::Source::Section

Inherits:
Base
  • Object
show all
Defined in:
lib/adva/static/import/source/section.rb

Direct Known Subclasses

Blog, Page

Constant Summary collapse

TYPES =
[Blog, Page]

Instance Attribute Summary

Attributes inherited from Base

#path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#<=>, #initialize, #model_name, #to_hash

Constructor Details

This class inherits a constructor from Adva::Static::Import::Source::Base

Class Method Details

.recognize(paths) ⇒ Object



9
10
11
# File 'lib/adva/static/import/source/section.rb', line 9

def recognize(paths)
  TYPES.map { |type| type.recognize(paths) }.flatten.compact.sort
end

Instance Method Details

#dataObject



26
27
28
# File 'lib/adva/static/import/source/section.rb', line 26

def data
  super.merge(:name => name, :slug => slug)
end

#nameObject



18
19
20
# File 'lib/adva/static/import/source/section.rb', line 18

def name
  @name ||= read.name || (root? ? 'Home' : path.filename.to_s.titleize)
end

#root?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/adva/static/import/source/section.rb', line 14

def root?
  path.root?
end

#slugObject



22
23
24
# File 'lib/adva/static/import/source/section.rb', line 22

def slug
  @slug ||= read.slug || SimpleSlugs::Slug.new(name).to_s
end