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.
13 14 15 16 17 18 19 20 21 |
# File 'lib/citation/citation.rb', line 13 def initialize @year = '' @sq = '' @url = '' @desc = '' @author = '' @title = '' @type = '' end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
12 13 14 |
# File 'lib/citation/citation.rb', line 12 def @author end |
#desc ⇒ Object
Returns the value of attribute desc.
12 13 14 |
# File 'lib/citation/citation.rb', line 12 def desc @desc end |
#sq ⇒ Object
Returns the value of attribute sq.
12 13 14 |
# File 'lib/citation/citation.rb', line 12 def sq @sq end |
#title ⇒ Object
Returns the value of attribute title.
12 13 14 |
# File 'lib/citation/citation.rb', line 12 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/citation/citation.rb', line 12 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
12 13 14 |
# File 'lib/citation/citation.rb', line 12 def url @url end |
#year ⇒ Object
Returns the value of attribute year.
12 13 14 |
# File 'lib/citation/citation.rb', line 12 def year @year end |
Instance Method Details
#out(format) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/citation/citation.rb', line 27 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
23 24 25 |
# File 'lib/citation/citation.rb', line 23 def puts return {year: @year, sq: @sq, desc: @desc, author: @author, title: @title, type: @type} end |