Class: DateTime

Inherits:
Object
  • Object
show all
Defined in:
lib/time_extended.rb

Overview

Extend and simplify Ruby class ‘DateTime`

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/time_extended.rb', line 3

def method_missing(method)
  options = ''

  params = method.to_s.split('')
  params.each do |el|
    options = "#{options}#{el}"
    options = "#{options} " if ('a'..'z').include?(el) || ('A'..'Z').include?(el)
  end
  options = "%#{options.split(' ').join(' %')}"

  self.class.send(:define_method, method) { strftime(options) }
  strftime(options)
end