Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/asciidoc-bib/extensions.rb
Overview
Two methods are added to extend the String class.
Instance Method Summary collapse
-
#html_to_asciidoc ⇒ Object
Converts html output produced by citeproc to asciidoc markup.
-
#is_i? ⇒ Boolean
Provides a check that a string is in integer.
Instance Method Details
#html_to_asciidoc ⇒ Object
Converts html output produced by citeproc to asciidoc markup.
36 37 38 39 40 41 42 |
# File 'lib/asciidoc-bib/extensions.rb', line 36 def html_to_asciidoc r = self.gsub(/<\/?i>/, '_') r = r.gsub(/<\/?b>/, '*') r = r.gsub(/<\/?span.*?>/, '') r = r.gsub(/\{|\}/, '') r end |
#is_i? ⇒ Boolean
Provides a check that a string is in integer. Taken from: stackoverflow.com/questions/1235863/test-if-a-string-is-basically-an-integer-in-quotes-using-ruby
47 48 49 |
# File 'lib/asciidoc-bib/extensions.rb', line 47 def is_i? !!(self =~ /^[-+]?[0-9]+$/) end |