Module: VirtualDate
- Defined in:
- lib/virtual_date.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
- .date_format(date, format) ⇒ Object
- .format ⇒ Object
- .format=(format) ⇒ Object
- .get_options(attributes) ⇒ Object
- .included(klass) ⇒ Object
- .to_date(string) ⇒ Object
Class Method Details
.date_format(date, format) ⇒ Object
17 18 19 |
# File 'lib/virtual_date.rb', line 17 def self.date_format date, format date.strftime(format) end |
.format ⇒ Object
9 10 11 |
# File 'lib/virtual_date.rb', line 9 def self.format @format || "%Y-%m-%d" end |
.format=(format) ⇒ Object
13 14 15 |
# File 'lib/virtual_date.rb', line 13 def self.format= format @format = format end |
.get_options(attributes) ⇒ Object
25 26 27 |
# File 'lib/virtual_date.rb', line 25 def self. attributes attributes.select {|opt| opt.class == Hash}.first end |
.included(klass) ⇒ Object
5 6 7 |
# File 'lib/virtual_date.rb', line 5 def self.included klass klass.extend ClassMethods end |
.to_date(string) ⇒ Object
21 22 23 |
# File 'lib/virtual_date.rb', line 21 def self.to_date string Chronic.parse(string) end |