Module: BibTeX

Defined in:
lib/bibtex.rb,
lib/bibtex/entry.rb,
lib/bibtex/error.rb,
lib/bibtex/lexer.rb,
lib/bibtex/names.rb,
lib/bibtex/value.rb,
lib/bibtex/parser.rb,
lib/bibtex/filters.rb,
lib/bibtex/version.rb,
lib/bibtex/elements.rb,
lib/bibtex/utilities.rb,
lib/bibtex/extensions.rb,
lib/bibtex/name_parser.rb,
lib/bibtex/replaceable.rb,
lib/bibtex/bibliography.rb,
lib/bibtex/compatibility.rb,
lib/bibtex/filters/latex.rb,
lib/bibtex/filters/linebreaks.rb

Overview

– BibTeX-Ruby Copyright (C) 2010-2015 Sylvester Keil <sylvester.keil.or.at>

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

This program 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>. ++

Defined Under Namespace

Modules: Extensions, Filters, Replaceable, Version Classes: ArgumentError, BibTeXError, Bibliography, Comment, Element, Entry, Error, Filter, Lexer, MetaContent, Name, NameParser, Names, ParseError, Parser, Preamble, String, Value

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.logObject

Returns the value of attribute log



49
50
51
# File 'lib/bibtex.rb', line 49

def log
  @log
end

Class Method Details

.names(string) ⇒ Object Also known as: name, parse_name, parse_names

Parses the given string as a BibTeX name value and returns a Names object.



49
50
51
# File 'lib/bibtex/utilities.rb', line 49

def names(string)
  Names.parse(string)
end

.open(file, options = {}, &block) ⇒ Object

Opens a BibTeX file or URI and returns a corresponding Bibliography object or, if a block is given, yields the Bibliography to the block, ensuring that the file is saved.



26
27
28
# File 'lib/bibtex/utilities.rb', line 26

def open(file, options = {}, &block)
  Bibliography.open(file, options, &block)
end

.parse(string, options = {}, &block) ⇒ Object

Parses the given string and returns a corresponding Bibliography object. Delegates to BibTeX.open if the string is a filename or URI.



32
33
34
35
36
37
38
39
40
41
# File 'lib/bibtex/utilities.rb', line 32

def parse(string, options = {}, &block)
  case
  when string.length < 260 && File.exist?(string)
    Bibliography.open(string, options, &block)
  when string =~ /^[a-z]+:\/\//i
    Bibliography.open(string, options)
  else
    Bibliography.parse(string, options)
  end
end

.valid?(file) ⇒ Boolean

Returns true if the given file is a valid BibTeX bibliography.

Returns:

  • (Boolean)


44
45
46
# File 'lib/bibtex/utilities.rb', line 44

def valid?(file)
  Bibliography.open(file).valid?
end