Class: Citation
- Inherits:
-
Object
- Object
- Citation
- Defined in:
- lib/citation.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Article, Article_to_be_submitted, Author, Book, Webpage, Workshop
Instance Attribute Summary collapse
-
#abstract ⇒ Object
quotes are director or parenthetical.
-
#authors ⇒ Object
authors should be an array of Author objects, or a string for an exact line.
-
#bibtype ⇒ Object
quotes are director or parenthetical.
-
#ident ⇒ Object
quotes are director or parenthetical.
-
#quotes ⇒ Object
quotes are director or parenthetical.
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ Citation
constructor
A new instance of Citation.
- #to_hash ⇒ Object
-
#to_yaml ⇒ Object
make the yaml look like a hash.
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
#abstract ⇒ Object
quotes are director or parenthetical
6 7 8 |
# File 'lib/citation.rb', line 6 def abstract @abstract end |
#authors ⇒ Object
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 end |
#bibtype ⇒ Object
quotes are director or parenthetical
6 7 8 |
# File 'lib/citation.rb', line 6 def bibtype @bibtype end |
#ident ⇒ Object
quotes are director or parenthetical
6 7 8 |
# File 'lib/citation.rb', line 6 def ident @ident end |
#quotes ⇒ Object
quotes are director or parenthetical
6 7 8 |
# File 'lib/citation.rb', line 6 def quotes @quotes end |
Instance Method Details
#to_hash ⇒ Object
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_yaml ⇒ Object
make the yaml look like a hash
69 70 71 |
# File 'lib/citation.rb', line 69 def to_yaml to_hash.to_yaml end |