Sha256: 2c19be5918bdd70622dd75c2caeac3c1085a3ccccadd9d739c077b0a361a23fc

Contents?: true

Size: 444 Bytes

Versions: 1

Compression:

Stored size: 444 Bytes

Contents

module Belajar
  class Chapter

    attr_reader :title, :path

    def initialize(path)
      @path = path
      @title = File.basename(path).gsub(/\_+/, ' ')
    end

    def units
      @units ||= Loading::Units.load(@path)
    end

    def started?
      units.reduce(false) { |started, unit| started ||= unit.mastered? }
    end

    def mastered?
      units.reduce(true) { |mastered, unit| mastered &&= unit.mastered? }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belajar-0.1.1 lib/belajar/chapter.rb