Class: Citation

Inherits:
Object
  • Object
show all
Defined in:
lib/citation.rb

Direct Known Subclasses

Article, Article_to_be_submitted, Book, Webpage, Workshop

Defined Under Namespace

Classes: Article, Article_to_be_submitted, Author, Book, Webpage, Workshop

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Citation

Returns a new instance of Citation.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/citation.rb', line 11

def initialize(hash=nil)
  @authors = nil
  @quotes = []
  # Citation::Article -> :article
  @bibtype = self.class.to_s.split('::')[-1].downcase.to_sym
  if hash
    hash.each do |x,v|
      send("#{x}=".to_sym, v)
    end
  end
end

Instance Attribute Details

#abstractObject

quotes are director or parenthetical



6
7
8
# File 'lib/citation.rb', line 6

def abstract
  @abstract
end

#authorsObject

authors should be an array of Author objects, or a string for an exact line



9
10
11
# File 'lib/citation.rb', line 9

def authors
  @authors
end

#bibtypeObject

quotes are director or parenthetical



6
7
8
# File 'lib/citation.rb', line 6

def bibtype
  @bibtype
end

#identObject

quotes are director or parenthetical



6
7
8
# File 'lib/citation.rb', line 6

def ident
  @ident
end

#quotesObject

quotes are director or parenthetical



6
7
8
# File 'lib/citation.rb', line 6

def quotes
  @quotes
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/citation.rb', line 23

def to_hash
  hash = {}
  others = instance_variables.select {|v| v != '@authors'}
  others.each do |var|
    hash[var[1..-1]] = instance_variable_get(var)
  end
  hash['bibtype'] = hash['bibtype'].to_s
  hash['authors'] = instance_variable_get('@authors').map {|v| v.to_s }
  hash
end

#to_yamlObject

make the yaml look like a hash



69
70
71
# File 'lib/citation.rb', line 69

def to_yaml
  to_hash.to_yaml
end