Class: Database::Author
- Inherits:
-
Struct
- Object
- Struct
- Database::Author
- Defined in:
- lib/database/author.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#name ⇒ Object
Returns the value of attribute name.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email
6 7 8 |
# File 'lib/database/author.rb', line 6 def email @email end |
#name ⇒ Object
Returns the value of attribute name
6 7 8 |
# File 'lib/database/author.rb', line 6 def name @name end |
#time ⇒ Object
Returns the value of attribute time
6 7 8 |
# File 'lib/database/author.rb', line 6 def time @time end |
Class Method Details
.parse(string) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/database/author.rb', line 7 def self.parse(string) name, email, time = string.split(/<|>/).map(&:strip) time = Time.strptime(time, TIME_FORMAT) Author.new(name, email, time) end |
Instance Method Details
#readable_time ⇒ Object
18 19 20 |
# File 'lib/database/author.rb', line 18 def readable_time time.strftime("%a %b %-d %H:%M:%S %Y %z") end |
#short_date ⇒ Object
14 15 16 |
# File 'lib/database/author.rb', line 14 def short_date time.strftime("%Y-%m-%d") end |
#to_s ⇒ Object
22 23 24 25 |
# File 'lib/database/author.rb', line 22 def to_s = time.strftime(TIME_FORMAT) "#{ name } <#{ email }> #{ }" end |