Sha256: 0e829e750743bb635f2bf5979683da25436a52b0d94b575715c4276d3684a44e

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

module TermNote
  module Pane
    class Chapter
      include Pane

      attr_accessor :title, :subtitle

      def initialize(options)
        @title = options[:title] || options['title']
        @subtitle = options[:subtitle] || options['subtitle']
      end

      def rows
        if subtitle
          title_rows + subtitle_rows
        else
          title_rows
        end
      end

      private

      def title_rows
        title.split('').each_slice(80).map do |row|
          row.join.center(width).bold
        end
      end

      def subtitle_rows
        subtitle.split('').each_slice(80).map do |row|
          row.join.center(width)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
termnote-1.1.0 lib/termnote/pane/chapter.rb
termnote-1.0.0 lib/termnote/pane/chapter.rb