Class: Citation::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

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

#authorObject

Returns the value of attribute author.



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

def author
  @author
end

#descObject

Returns the value of attribute desc.



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

def desc
  @desc
end

#sqObject

Returns the value of attribute sq.



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

def sq
  @sq
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

#yearObject

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

#putsObject



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