Sha256: 614858ff76ae448ab1f25540d7821b968ef0a89476365bb9afc57e55674171dd

Contents?: true

Size: 637 Bytes

Versions: 15

Compression:

Stored size: 637 Bytes

Contents

module LocalPac
  module Actions
    class PrintTitle
      private

      attr_reader :title, :width

      public

      def initialize(title, width = 0)
        @title = title
        @width = width
      end

      def run
        puts long_line
        puts full_title
        puts long_line
        print "\n"
      end

      private

      def long_line
        '#' * full_title.size 
      end

      def full_title
        header + ' ' + title + ' ' + header
      end

      def header
        if width > title.size
          '#' * ((width - title.size) / 2)
        else
          '#'
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
local_pac-0.10.2 lib/local_pac/actions/print_title.rb
local_pac-0.10.1 lib/local_pac/actions/print_title.rb
local_pac-0.10.0 lib/local_pac/actions/print_title.rb
local_pac-0.9.0 lib/local_pac/actions/print_title.rb
local_pac-0.7.0 lib/local_pac/actions/print_title.rb
local_pac-0.6.3 lib/local_pac/actions/print_title.rb
local_pac-0.6.2 lib/local_pac/actions/print_title.rb
local_pac-0.6.1 lib/local_pac/actions/print_title.rb
local_pac-0.5.0 lib/local_pac/actions/print_title.rb
local_pac-0.4.0 lib/local_pac/actions/print_title.rb
local_pac-0.3.0 lib/local_pac/actions/print_title.rb
local_pac-0.2.3 lib/local_pac/actions/print_title.rb
local_pac-0.2.2 lib/local_pac/actions/print_title.rb
local_pac-0.2.1 lib/local_pac/actions/print_title.rb
local_pac-0.2.0 lib/local_pac/actions/print_title.rb