Class: Hylite

Inherits:
Object
  • Object
show all
Defined in:
lib/hylite.rb,
lib/hylite/cli.rb,
lib/hylite/version.rb,
lib/hylite/hyliters.rb,
lib/hylite/choose_hyliter.rb

Defined Under Namespace

Modules: ChooseHyliter Classes: CLI, CodeRay, Hyliter, Pygments, Rouge

Constant Summary collapse

VERSION =
'1.0.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to_highlight, options = {}) ⇒ Hylite

Returns a new instance of Hylite.



10
11
12
13
14
15
16
17
18
# File 'lib/hylite.rb', line 10

def initialize(to_highlight, options={})
  self.to_highlight = to_highlight
  options.each do |key, value|
    if key =~ /^l/
      self.lang = value
    end
  end
  self.lang ||= 'ruby'
end

Instance Attribute Details

#langObject

Returns the value of attribute lang.



8
9
10
# File 'lib/hylite.rb', line 8

def lang
  @lang
end

Class Method Details

.call(*args) ⇒ Object



4
5
6
# File 'lib/hylite.rb', line 4

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callObject



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

def call
  code = to_highlight
  code = code.read if code.respond_to? :read
  hyliter(code, lang).call
end