Module: Sancho::Model
- Defined in:
- lib/sancho/model.rb,
lib/sancho/model/page.rb,
lib/sancho/model/site.rb,
lib/sancho/model/config.rb
Overview
Model namespace
Constant Summary collapse
- Page =
Page model
Data.define(:source, :url, :date) do # @param source [String] filename # @param url [String] def self.from(source, url = '') url = File.basename(source, '.md').downcase + '.html' if url.empty? date = File.mtime(source).to_date new(source:, url:, date:) end end
- Site =
Site model
Data.define(:domain, :title, :pages) do extend Forwardable def_delegator :pages, :each, :each_page def pages_by_date pages.sort{|a, b| b.date <=> a.date } end def add(page) with(pages: pages.push(page)) end alias << add end
- Config =
Config model
Data.define(:directory, :domain, :title, :pages)