Sha256: 78cd513c89056800070e58cf0eb82e840d3d130e5b37a225c1823f082430717c

Contents?: true

Size: 827 Bytes

Versions: 8

Compression:

Stored size: 827 Bytes

Contents

module BibTeX
  
  #
  # Represents a lexical or syntactical error.
  #
  class Error < Element
    
    attr_reader :trace
    
    def initialize(trace=[])
      @trace = trace
    end

    def trace=(trace)
      raise(ArgumentError, "BibTeX::Error trace must be of type Array; was: #{trace.class.name}.") unless trace.kind_of?(Array)
      @trace = trace
    end
    
    def content
      @trace.map { |e| e[1] }.join
    end
    
    # Called when the element was added to a bibliography.
    def added_to_bibliography(bibliography)
      super(bibliography)
      bibliography.errors << self
      self
    end
    
    # Called when the element was removed from a bibliography.
    def removed_from_bibliography(bibliography)
      super(bibliography)
      bibliography.errors.delete(self)
      self
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bibtex-ruby-1.3.1 lib/bibtex/error.rb
bibtex-ruby-1.3.0 lib/bibtex/error.rb
bibtex-ruby-1.2.1 lib/bibtex/error.rb
bibtex-ruby-1.2.0 lib/bibtex/error.rb
bibtex-ruby-1.1.2 lib/bibtex/error.rb
bibtex-ruby-1.1.1 lib/bibtex/error.rb
bibtex-ruby-1.1.0 lib/bibtex/error.rb
bibtex-ruby-1.0.0 lib/bibtex/error.rb