Sha256: 0cbf116f3426602f9dd9ab24c3bb8728c32914673c606cbc7a5dd8dd5c6ca890

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'hexdump/theme/rule'

module Hexdump
  #
  # Represents a hexdump theme (styling + highlighting).
  #
  # @api semipublic
  #
  # @since 1.0.0
  #
  class Theme

    # The index styling/highlights.
    #
    # @return [Rule, nil]
    #
    # @api public
    attr_reader :index

    # The numeric styling/highlights.
    #
    # @return [Rule, nil]
    #
    # @api public
    attr_reader :numeric

    # The chars styling/highlights.
    #
    # @return [Rule, nil]
    #
    # @api public
    attr_reader :chars

    #
    # Initializes the theme.
    #
    # @param [Hash{:index,:numeric,:chars => Symbol,Array<Symbol>,nil}] style
    #   The default style of the index, numeric, and/or chars columns.
    #
    # @param [Hash{:index,:numeric,:chars => Hash{String,Regexp => Symbol,Array<Symbol>},nil}] highlights
    #   The highlighting rules for the index, numeric, and/or chars columns.
    #
    def initialize(style: {}, highlights: {})
      @index   = Rule.new(
                   style:      style[:index],
                   highlights: highlights[:index]
                 )

      @numeric = Rule.new(
                   style:      style[:numeric],
                   highlights: highlights[:numeric]
                 )

      @chars   = Rule.new(
                   style:      style[:chars],
                   highlights: highlights[:chars]
                )
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hexdump-1.0.0 lib/hexdump/theme.rb