Module: EPUB

Defined in:
lib/epub/cfi/version.rb,
lib/epub/cfi.rb,
lib/epub/cfi/parser.tab.rb

Overview

Copyright (c) 2017 KITAITI Makoto (KitaitiMakoto at gmail.com)

EPUB CFI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPUB CFI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPUB CFI. If not, see http://www.gnu.org/licenses/.

Defined Under Namespace

Modules: CFI

Class Method Summary collapse

Class Method Details

.CFI(string) ⇒ CFI

Creates a new CFI object from the given string and return it.

Examples:

Creates from a URI fragment string

EPUB::CFI("epubcfi(/6/14[chap05ref]!/4[body01]/10/2/1:3[2^[1^]])")
#=> #<EPUB::CFI::Location:/6/14[chap05ref]!/4[body01]/10/2/1:3[2^[1^]]>

Creates from a path string

EPUB::CFI("/6/14[chap05ref]!/4[body01]/10/2/1:3[2^[1^]]")
#=> #<EPUB::CFI::Location:/6/14[chap05ref]!/4[body01]/10/2/1:3[2^[1^]]>

Parameters:

  • string (String, CFI)

Returns:

  • (CFI)

    CFI parsed from string when string is a String. string itself when it’s a CFI

Raises:

  • (Racc::ParseError)

    if given string is invalid

See Also:



113
114
115
116
117
118
119
120
# File 'lib/epub/cfi/parser.rb', line 113

def EPUB::CFI(string)
  case string
  when EPUB::CFI::Location, EPUB::CFI::Range
    string
  else
    EPUB::CFI.parse(string)
  end
end