Sha256: 453f6516d14e51679c581feb7d3f3bd557660fb8c35c9d02b64512453b6f5e3e

Contents?: true

Size: 1010 Bytes

Versions: 2

Compression:

Stored size: 1010 Bytes

Contents

#
# $Id: book.rb 4315 2009-09-02 04:15:24Z kmuto $
#
# Copyright (c) 2002-2008 Minero Aoki
#               2009 Minero Aoki, Kenshi Muto
#
# This program is free software.
# You can distribute or modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of the GNU LGPL, see the file "COPYING".
#
require 'review/book/compilable'
module ReVIEW
  module Book
    class Part
      include Compilable

      def initialize(book, number, chapters, name="")
        @book = book
        @number = number
        @chapters = chapters
        @path = name
        @name = name ? File.basename(name, '.*') : nil
      end

      attr_reader :number
      attr_reader :chapters
      attr_reader :name

      def each_chapter(&block)
        @chapters.each(&block)
      end

      def volume
        Volume.sum(@chapters.map {|chap| chap.volume })
      end

      def file?
        (name.present? and path =~ /\.re\z/) ? true : false
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
review-1.1.0 lib/review/book/part.rb
tmtms-review-1.0.0 lib/review/book/part.rb