Class: Setsumei::Describable::DateTimeAttribute
- Inherits:
-
Object
- Object
- Setsumei::Describable::DateTimeAttribute
- Defined in:
- lib/setsumei/describable/date_time_attribute.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cast(value) ⇒ Object
-
#initialize(type, format, parser) ⇒ DateTimeAttribute
constructor
A new instance of DateTimeAttribute.
Constructor Details
#initialize(type, format, parser) ⇒ DateTimeAttribute
Returns a new instance of DateTimeAttribute.
5 6 7 8 |
# File 'lib/setsumei/describable/date_time_attribute.rb', line 5 def initialize type, format, parser @type, @parser = type, parser @format = format || '%Y-%m-%d %H:%M' end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
9 10 11 |
# File 'lib/setsumei/describable/date_time_attribute.rb', line 9 def format @format end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
9 10 11 |
# File 'lib/setsumei/describable/date_time_attribute.rb', line 9 def parser @parser end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/setsumei/describable/date_time_attribute.rb', line 9 def type @type end |
Instance Method Details
#==(other) ⇒ Object
11 12 13 |
# File 'lib/setsumei/describable/date_time_attribute.rb', line 11 def == other type == other || self.class == other end |
#cast(value) ⇒ Object
15 16 17 |
# File 'lib/setsumei/describable/date_time_attribute.rb', line 15 def cast value parser.strptime value, format end |