Class: APA

Inherits:
RuleBase show all
Defined in:
lib/citation/rules/apa.rb

Instance Attribute Summary

Attributes inherited from RuleBase

#matcher

Class Method Summary collapse

Class Method Details

.fetch(string, base) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/citation/rules/apa.rb', line 13

def self.fetch(string, base)
  title = @matcher[0] unless @matcher.nil?
  title.gsub!(/"|\(\)\. /,'')
  string.slice!(title)

  s = string.split('(). ')
  author = s.shift
  desc   = s.shift
  type   = 'APA'.to_sym
  string.slice!(author) unless string.empty?
  string.slice!(desc) unless string.empty?
  return string, title, author, desc, type
end

.satisfy?(string, base) ⇒ Boolean



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

def self.satisfy?(string, base)
  @matcher = string.match(/\(\)\. .+\. /)
  base.type.empty? and not @matcher.nil?
end