Class: Arcticelvis::Base
- Inherits:
-
Object
- Object
- Arcticelvis::Base
- Defined in:
- lib/arcticelvis/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Base
constructor
Initializes the object using the given attributes.
-
#parse_timestamps ⇒ Object
Parses UNIX timestamps and creates Time objects.
-
#set_attributes(attributes) ⇒ Object
Sets the attributes.
Constructor Details
#initialize(attributes = {}) ⇒ Base
Initializes the object using the given attributes
9 10 11 12 |
# File 'lib/arcticelvis/base.rb', line 9 def initialize(attributes = {}) set_attributes(attributes) end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/arcticelvis/base.rb', line 4 def created_at @created_at end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/arcticelvis/base.rb', line 4 def updated_at @updated_at end |
Instance Method Details
#parse_timestamps ⇒ Object
Parses UNIX timestamps and creates Time objects.
24 25 26 27 |
# File 'lib/arcticelvis/base.rb', line 24 def @created_at = DateTime.parse(created_at) if created_at @updated_at = DateTime.parse(updated_at) if updated_at end |
#set_attributes(attributes) ⇒ Object
Sets the attributes
17 18 19 20 21 |
# File 'lib/arcticelvis/base.rb', line 17 def set_attributes(attributes) attributes.each_pair do |key, value| instance_variable_set("@#{key}", value) end end |