Class: PrawnEncoder

Inherits:
CodeRay::Encoders::Encoder
  • Object
show all
Defined in:
lib/coderay/prawn_encoder.rb

Constant Summary collapse

COLORS =
{
  default: "E6E1DC",
  comment: "BC9458",
  constant: "DA4939",
  instance_variable: "D0D0FF",
  integer: "56D65E",
  float: "56D65E",
  inline_delimiter: "EF804F",
  keyword: "CC7833",
  method: "FFC66D",
  string: "A5C261",
  symbol: "6D9CBE"
}

Instance Method Summary collapse

Instance Method Details

#begin_group(kind) ⇒ Object



32
33
34
# File 'lib/coderay/prawn_encoder.rb', line 32

def begin_group(kind)
  @open << kind
end

#end_group(kind) ⇒ Object



36
37
38
# File 'lib/coderay/prawn_encoder.rb', line 36

def end_group(kind)
  @open.pop
end

#setup(options) ⇒ Object



20
21
22
23
24
# File 'lib/coderay/prawn_encoder.rb', line 20

def setup(options)
  super
  @out  = []
  @open = []
end

#text_token(text, kind) ⇒ Object



26
27
28
29
30
# File 'lib/coderay/prawn_encoder.rb', line 26

def text_token(text, kind)
  color = COLORS[kind] || COLORS[@open.last] || COLORS[:default]

  @out << {:text => text, :color => color}
end