Sha256: cbe87986cda31fc5edc27ce899319dbd16b49b8c59ce19f5e251a17ff4c633dd

Contents?: true

Size: 686 Bytes

Versions: 5

Compression:

Stored size: 686 Bytes

Contents

require 'forwardable'

module Everything
  class Piece
    extend Forwardable

    attr_reader :full_path

    def initialize(full_path)
      @full_path = full_path
    end

    def content
      @content ||= Content.new(full_path)
    end

    def_delegators :content, :body, :raw_markdown, :raw_markdown=, :title

    def metadata
      @metadata ||= Metadata.new(full_path)
    end

    def public?
      metadata['public']
    end

    def_delegators :metadata, :raw_yaml, :raw_yaml=

    def name
      File.basename(full_path)
    end

    def save
      content.save
      metadata.save
    end
  end
end

require 'everything/piece/content'
require 'everything/piece/metadata'

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
everything-core-0.0.12 lib/everything/piece.rb
everything-core-0.0.11 lib/everything/piece.rb
everything-core-0.0.10 lib/everything/piece.rb
everything-core-0.0.9 lib/everything/piece.rb
everything-core-0.0.8 lib/everything/piece.rb