module EPUB
Copyright © 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 <www.gnu.org/licenses/>.
Public Class Methods
Creates a new {CFI} object from the given string and return it.
@example 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^]]>
@example 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^]]>
@param string [String, CFI] @return [CFI] CFI
parsed from string
when string
is a String. string
itself when it's a CFI
@raise [Racc::ParseError] if given string is invalid @see CFI.parse
# File lib/epub/cfi/parser.rb, line 109 def EPUB::CFI(string) string.kind_of?(EPUB::CFI::Location) || string.kind_of?(EPUB::CFI::Range) ? string : EPUB::CFI.parse(string) end