Class: Citation::Author
- Inherits:
-
Object
- Object
- Citation::Author
- Defined in:
- lib/citation.rb
Instance Attribute Summary collapse
-
#initials ⇒ Object
readonly
INITIALS should be with NO spaces, all caps.
-
#last ⇒ Object
readonly
INITIALS should be with NO spaces, all caps.
Class Method Summary collapse
-
.from_s(string) ⇒ Object
TODO: make this smarter for initials.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(last, initials) ⇒ Author
constructor
A new instance of Author.
- #inspect ⇒ Object
- #to_s ⇒ Object
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
#initials ⇒ Object (readonly)
INITIALS should be with NO spaces, all caps
167 168 169 |
# File 'lib/citation.rb', line 167 def initials @initials end |
#last ⇒ Object (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 |
#inspect ⇒ Object
172 173 174 |
# File 'lib/citation.rb', line 172 def inspect "<#{@last}, #{initials}>" end |
#to_s ⇒ Object
176 177 178 |
# File 'lib/citation.rb', line 176 def to_s "#{@last}, #{@initials}" end |