Module: Kulriir
- Defined in:
- lib/kulriir.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- KULRII_HOST =
'kulrii.heroku.com'
Class Method Summary collapse
Instance Method Summary collapse
-
#highlight(options = {}) ⇒ Object
return a syntax-highlighted version of the string.
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/kulriir.rb', line 7 def self.included(base) base.extend ClassMethods end |
.syntaxes ⇒ Object
35 36 37 |
# File 'lib/kulriir.rb', line 35 def syntaxes REXML::Document.new(RestClient.get("http://#{KULRII_HOST}/syntaxes")).elements.collect('syntaxes/syntax') { |e| e.text } end |
.themes ⇒ Object
39 40 41 |
# File 'lib/kulriir.rb', line 39 def themes REXML::Document.new(RestClient.get("http://#{KULRII_HOST}/themes")).elements.collect('themes/theme') { |e| e.text } end |
Instance Method Details
#highlight(options = {}) ⇒ Object
return a syntax-highlighted version of the string
options:
numbers: boolean indicating whether or not to include line numbers line_numbers: legacy equivalent for 'numbers' option syntax: language to use for highlighting language: legacy equivalent for 'syntax' option theme: theme for highlighting
25 26 27 28 29 30 31 32 |
# File 'lib/kulriir.rb', line 25 def highlight( = {}) [:numbers] = .delete(:line_numbers) if .include?(:line_numbers) [:syntax] = .delete(:language) if .include?(:language) [:syntax] ||= 'ruby' RestClient.post "http://#{KULRII_HOST}/parse", .merge(:text => self) end |