Class: PR::Fields::DateField
- Inherits:
-
Object
- Object
- PR::Fields::DateField
- Defined in:
- lib/pr/fields/date_field.rb
Constant Summary collapse
- Format =
'%d/%m/%Y'
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(value = '', options = {}) ⇒ DateField
constructor
A new instance of DateField.
- #populate(date) ⇒ Object
- #raw ⇒ Object
Constructor Details
#initialize(value = '', options = {}) ⇒ DateField
Returns a new instance of DateField.
7 8 9 |
# File 'lib/pr/fields/date_field.rb', line 7 def initialize value = '', = {} @value, @options = value, end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/pr/fields/date_field.rb', line 10 def @options end |
Instance Method Details
#convert ⇒ Object
20 21 22 23 24 |
# File 'lib/pr/fields/date_field.rb', line 20 def convert Date.strptime(@value,Format) rescue ArgumentError raise InvalidValue end |
#populate(date) ⇒ Object
16 17 18 |
# File 'lib/pr/fields/date_field.rb', line 16 def populate date @value = date.strftime Format end |
#raw ⇒ Object
12 13 14 |
# File 'lib/pr/fields/date_field.rb', line 12 def raw @value end |