Sha256: 8f4e4bddbf821842ebe278a3243f3be0eb3522e4998d2ae9f9f8c06a3e4ce5f9

Contents?: true

Size: 467 Bytes

Versions: 1

Compression:

Stored size: 467 Bytes

Contents

module Florby
  class Collection
    def initialize
      files = Dir.glob(File.join(Dir.pwd, 'src', '*.md'))
      @hash = files.map { |file| [File.basename(file).gsub(/\.md$/, ''), Page.new(file: file)] }.to_h
    end

    def titles
      @hash.keys
    end

    def all_pages
      @hash.values.sort_by(&:created).reverse
    end

    def pages
      all_pages.reject(&:exclude_from_collections?)
    end

    def find(title)
      @hash[title]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
florby-0.1.0 lib/florby/collection.rb