Class: Section
- Inherits:
-
Zarchitect
- Object
- Zarchitect
- Section
- Defined in:
- lib/zarchitect/section.rb
Constant Summary
Constants inherited from Zarchitect
Zarchitect::ASSETDIR, Zarchitect::ASSETSDIR, Zarchitect::BUILDIR, Zarchitect::CONFIGDIR, Zarchitect::DEBUGSDIR, Zarchitect::DRAFTDIR, Zarchitect::FILEDIR, Zarchitect::FILESDIR, Zarchitect::HTMLDIR, Zarchitect::LAYOUTDIR, Zarchitect::NODEDIR, Zarchitect::SHARESDIR, Zarchitect::VERSION
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #all_posts ⇒ Object
- #build_html ⇒ Object
- #find_category(key) ⇒ Object
-
#initialize(conf) ⇒ Section
constructor
A new instance of Section.
- #posts ⇒ Object
- #write_html ⇒ Object
Methods inherited from Zarchitect
Constructor Details
#initialize(conf) ⇒ Section
Returns a new instance of Section.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/zarchitect/section.rb', line 4 def initialize(conf) @index = false GPI.print "Initializing Section #{conf.key}.", GPI::CLU.check_option('v') @conf = conf @key = conf.key @name = @conf.name.clone if @conf.index @url = "/index.html" else @url = "/#{@conf.key}/index.html" end create_dir fetch_categories fetch_posts sort_posts if @conf.collection && @conf.categorize @categories.each do |c| c.setup_index c. if @conf. end end setup_index end |
Instance Attribute Details
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
2 3 4 |
# File 'lib/zarchitect/section.rb', line 2 def categories @categories end |
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
2 3 4 |
# File 'lib/zarchitect/section.rb', line 2 def conf @conf end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
2 3 4 |
# File 'lib/zarchitect/section.rb', line 2 def index @index end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'lib/zarchitect/section.rb', line 2 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/zarchitect/section.rb', line 2 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
2 3 4 |
# File 'lib/zarchitect/section.rb', line 2 def url @url end |
Instance Method Details
#all_posts ⇒ Object
36 37 38 |
# File 'lib/zarchitect/section.rb', line 36 def all_posts @posts end |
#build_html ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/zarchitect/section.rb', line 40 def build_html posts.each { |p| p.build_html } if @categories @categories.each { |c| c.build_html } end @index.build_html unless @conf.has_option?("file") end |
#find_category(key) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/zarchitect/section.rb', line 56 def find_category(key) @categories.each do |c| return c if c.key == key end nil end |
#posts ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/zarchitect/section.rb', line 28 def posts if GPI::CLU.check_option('D') @posts else @posts.select { |p| p.draft == false } end end |
#write_html ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/zarchitect/section.rb', line 48 def write_html posts.each { |p| p.write_html } if @categories @categories.each { |c| c.write_html } end @index.write_html unless @conf.has_option?("file") end |