Class: Rembrandt::Engines::WebService

Inherits:
Object
  • Object
show all
Defined in:
lib/rembrandt/engines/web_service.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/rembrandt/engines/web_service.rb', line 15

def self.available?
  site = Net::HTTP.new('pygmentize.herokuapp.com', 80)
  site.request_head('/').code == "200"
end

Instance Method Details

#highlight(input, language) ⇒ Object



7
8
9
# File 'lib/rembrandt/engines/web_service.rb', line 7

def highlight(input, language)
  Net::HTTP.post_form(url, {'lang'=>language, 'code'=>input}).body
end

#urlObject



11
12
13
# File 'lib/rembrandt/engines/web_service.rb', line 11

def url
  @url ||= URI.parse('http://pygmentize.herokuapp.com/')
end