Module: EPUB::CFI
- Defined in:
- lib/epub/cfi.rb,
lib/epub/cfi/parser.rb,
lib/epub/cfi/version.rb,
lib/epub/cfi/parser.tab.rb
Defined Under Namespace
Classes: CharacterOffset, IDAssertion, Location, Parser, Path, Range, Step, TemporalSpatialOffset, TextLocationAssertion
Constant Summary collapse
- SPECIAL_CHARS =
"5E", "5B", "5D", "28", "29", "2C", "3B", "3D"
'^[](),;='
- RE_ESCAPED_SPECIAL_CHARS =
Regexp.escape(SPECIAL_CHARS)
- VERSION =
epub-cfi version
"0.1.3"
Class Method Summary collapse
-
.escape(string) ⇒ String
Escapes special characters in string.
-
.parse(string) ⇒ CFI
Parses the given string, creates a new CFI object and return it.
-
.unescape(string) ⇒ String
Unescape escaped characters in string.
Class Method Details
.escape(string) ⇒ String
Escapes special characters in string
16 17 18 |
# File 'lib/epub/cfi.rb', line 16 def escape(string) string.gsub(/([#{RE_ESCAPED_SPECIAL_CHARS}])/o, '^\1') end |
.parse(string) ⇒ CFI
Parses the given string, creates a new EPUB::CFI object and return it.
94 95 96 |
# File 'lib/epub/cfi/parser.rb', line 94 def parse(string) EPUB::CFI::Parser.parse(string) end |
.unescape(string) ⇒ String
Unescape escaped characters in string
27 28 29 |
# File 'lib/epub/cfi.rb', line 27 def unescape(string) string.gsub(/\^([#{RE_ESCAPED_SPECIAL_CHARS}])/o, '\1') end |