class CodeRay::Encoders::TokenKindFilter

See also: CommentFilter
Exclusion wins over inclusion.
Default: :all, which means all tokens are included.
One or many symbols (in an array) which shall be included.
=== :include
Default: []
One or many symbols (in an Array) which shall be excluded.
=== :exclude
== Options
A Filter that selects tokens based on their token kind.

def begin_group kind

stream, even if their kinds match.
If it does not, all tokens inside the group are excluded from the

conditions.
Add the token group to the output stream if +kind+ matches the
def begin_group kind
  if @group_excluded
    @group_excluded += 1
  elsif include_group? kind
    super
  else
    @group_excluded = 1
  end
end

def begin_line kind

See +begin_group+.
def begin_line kind
  if @group_excluded
    @group_excluded += 1
  elsif include_group? kind
    super
  else
    @group_excluded = 1
  end
end

def end_group kind

if an exluded group has ended.
Take care of re-enabling the delegation of tokens to the output stream
def end_group kind
  if @group_excluded
    @group_excluded -= 1
    @group_excluded = false if @group_excluded.zero?
  else
    super
  end
end

def end_line kind

See +end_group+.
def end_line kind
  if @group_excluded
    @group_excluded -= 1
    @group_excluded = false if @group_excluded.zero?
  else
    super
  end
end

def include_group? kind

def include_group? kind
   (@include == :all || @include.include?(kind)) &&
  !(@exclude == :all || @exclude.include?(kind))
end

def include_text_token? text, kind

def include_text_token? text, kind
  include_group? kind
end

def setup options

def setup options
  super
  
  @group_excluded = false
  @exclude = options[:exclude]
  @exclude = Array(@exclude) unless @exclude == :all
  @include = options[:include]
  @include = Array(@include) unless @include == :all
end

def text_token text, kind

Add the token to the output stream if +kind+ matches the conditions.
def text_token text, kind
  super if !@group_excluded && include_text_token?(text, kind)
end