Class: Citation::Base
- Inherits:
-
Object
- Object
- Citation::Base
- Defined in:
- lib/citation/citation.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#sq ⇒ Object
Returns the value of attribute sq.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #out(format) ⇒ Object
- #puts ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 17 18 |
# File 'lib/citation/citation.rb', line 10 def initialize @year = '' @sq = '' @url = '' @desc = '' @author = '' @title = '' @type = '' end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
9 10 11 |
# File 'lib/citation/citation.rb', line 9 def @author end |
#desc ⇒ Object
Returns the value of attribute desc.
9 10 11 |
# File 'lib/citation/citation.rb', line 9 def desc @desc end |
#sq ⇒ Object
Returns the value of attribute sq.
9 10 11 |
# File 'lib/citation/citation.rb', line 9 def sq @sq end |
#title ⇒ Object
Returns the value of attribute title.
9 10 11 |
# File 'lib/citation/citation.rb', line 9 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
9 10 11 |
# File 'lib/citation/citation.rb', line 9 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/citation/citation.rb', line 9 def url @url end |
#year ⇒ Object
Returns the value of attribute year.
9 10 11 |
# File 'lib/citation/citation.rb', line 9 def year @year end |
Instance Method Details
#out(format) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/citation/citation.rb', line 24 def out(format) str = '' case format.downcase when 'MLA' str = "#{@author} \"#{@title}\" #{@desc} (#{@year})" when 'APA' str = "#{@author} (#{@year}) #{@title} #{@desc}" when 'ISO' str = "#{@author} #{@title} #{@desc}, #{@year}." when 'bibtex' str = "@article{#{@author.gsub(' ','').gsub(/( |\.|,)/,'').downcase[0..5]}#{@year}#{@title.split.select{|i| i.length >3 }[0].downcase}, title={#{@title}}, author={#{@author.gsub(', and ',', ')}}, year={#{@year}}, journal={#{@desc}} }" end str end |
#puts ⇒ Object
20 21 22 |
# File 'lib/citation/citation.rb', line 20 def puts return {year: @year, sq: @sq, desc: @desc, author: @author, title: @title, type: @type} end |