Class: BibTeX::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/btparse-ruby/BibTeX.rb,
ext/btparse-ruby/btparse_ruby.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



6
7
8
# File 'lib/btparse-ruby/BibTeX.rb', line 6

def fields
  @fields
end

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/btparse-ruby/BibTeX.rb', line 6

def key
  @key
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/btparse-ruby/BibTeX.rb', line 6

def type
  @type
end

Instance Method Details

#to_sObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/btparse-ruby/BibTeX.rb', line 8

def to_s
  str = "@#{type}{#{key},\n"

  fields.each do |name, value|
    str += "\t#{BibTeX.purify(name)} = "
    if name == "author"
      str += BibTeX.parse_author(value).inspect
    else
      str += "'" + BibTeX.purify(value) + "'"
    end
    str += "\n"
  end

  str += "}"
end