Sha256: 8efc33a4afc7e4a5ae21afeaa6781ac11dfbcb4ff435513ef02904c0aea54d58

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

require_relative 'pane/chapter'
require_relative 'pane/code'
require_relative 'pane/list'
require_relative 'pane/text'
module TermNote
  module Pane
    attr_accessor :show, :height, :width, :rows

    def call(window_size)
      window_height, window_width = window_size
      @width = window_width - (window_width * 0.2)
      @height = window_height / 2
      clear
      render
    end

    private

    def clear
      system("clear")
    end

    def render
      puts space + formated_rows + space + footer
    end

    def gutter
      " " * (width * 0.1)
    end

    def space
      "\n" * (height - rows.size)
    end

    def footer
      "[#{show.panes.index(self) + 1}/#{show.panes.size}]".bold
    end

    def formated_rows
      rows.map { |row| gutter + row }.join("\n")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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