Sha256: 974e7d9d2dbf281fa9ab1cd0a8b72298c0e4ad3232cb6e0614e6dab2cafb8b9d

Contents?: true

Size: 709 Bytes

Versions: 14

Compression:

Stored size: 709 Bytes

Contents

module Vedeu
  class Base
    class << self
      def escape_sequence(colour = nil)
        new(colour).escape_sequence
      end
    end

    def initialize(colour = nil)
      @colour = colour
    end

    def escape_sequence
      [Esc.esc, prefix, code, suffix].join
    end

    private

    attr_reader :colour

    def code
      no_colour || named || html || default
    end

    def no_colour
      default unless colour
    end

    def named
      codes[colour] || codes[:default] if named?
    end

    def named?
      colour.is_a?(Symbol)
    end

    def html
      Translator.translate(colour)
    end

    def default
      codes[:default]
    end

    def suffix
      'm'
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
vedeu-0.0.17 lib/vedeu/output/base.rb
vedeu-0.0.16 lib/vedeu/output/base.rb
vedeu-0.0.15 lib/vedeu/output/base.rb
vedeu-0.0.14 lib/vedeu/output/base.rb
vedeu-0.0.13 lib/vedeu/output/base.rb
vedeu-0.0.12 lib/vedeu/output/base.rb
vedeu-0.0.11 lib/vedeu/output/base.rb
vedeu-0.0.10 lib/vedeu/output/base.rb
vedeu-0.0.9 lib/vedeu/output/base.rb
vedeu-0.0.8 lib/vedeu/output/base.rb
vedeu-0.0.7 lib/vedeu/output/base.rb
vedeu-0.0.6 lib/vedeu/output/base.rb
vedeu-0.0.5 lib/vedeu/output/base.rb
vedeu-0.0.4 lib/vedeu/output/base.rb