Sha256: 0def9caca09758f04221cd5be5624dccf97e934115a7b4c889b57c8818622dfd

Contents?: true

Size: 661 Bytes

Versions: 2

Compression:

Stored size: 661 Bytes

Contents

class Serious::Page < Serious::Article
  class << self
    #
    # Returns all pages
    #
    def all
      @pages ||= page_paths.map { |path| new(path) }
    end
    
    def find(permalink)
      all.find_all {|page| page.permalink == permalink }.first
    end
    
    private
    
      # Returns all page files in pages path
      def page_paths
        @pages_paths ||= Dir[File.join(Serious.pages, '*')].sort
      end
  end
  
  def url
    "/pages/#{permalink}"
  end
  
  private
  
    # Will extract the permalink from the filename.
    def extract_date_and_permalink!
      @permalink = File.basename(path).split('.')[0...-1].join("")
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
serious-0.2.4 lib/serious/page.rb
serious-0.2.3 lib/serious/page.rb