Class: Citation::Author

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(last, initials) ⇒ Author

Returns a new instance of Author.



168
169
170
171
# File 'lib/citation.rb', line 168

def initialize(last, initials)
  @last = last
  @initials = initials
end

Instance Attribute Details

#initialsObject (readonly)

INITIALS should be with NO spaces, all caps



167
168
169
# File 'lib/citation.rb', line 167

def initials
  @initials
end

#lastObject (readonly)

INITIALS should be with NO spaces, all caps



167
168
169
# File 'lib/citation.rb', line 167

def last
  @last
end

Class Method Details

.from_s(string) ⇒ Object

TODO: make this smarter for initials



181
182
183
184
185
186
# File 'lib/citation.rb', line 181

def self.from_s(string)
  pieces = string.split(', ')
  last = pieces.shift
  initials = pieces.join(', ')
  self.new(last, initials)
end

Instance Method Details

#==(other) ⇒ Object



188
189
190
# File 'lib/citation.rb', line 188

def ==(other)
  [self.last, self.initials] == [other.last, other.initials]
end

#inspectObject



172
173
174
# File 'lib/citation.rb', line 172

def inspect
  "<#{@last}, #{initials}>"
end

#to_sObject



176
177
178
# File 'lib/citation.rb', line 176

def to_s
  "#{@last}, #{@initials}"    
end