Class: Textigniter::Plugins::CreatedAt

Inherits:
Object
  • Object
show all
Defined in:
lib/textigniter/plugins/created_at.rb

Instance Method Summary collapse

Instance Method Details

#parse(h) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/textigniter/plugins/created_at.rb', line 3

def parse(h)
  # get the value to work with
  value = h['created_at']      
  # is this a valid date?
  valid = Date.parse(value) rescue false
  # if valid, pass value back
  if valid != false
    created_at = value
  # if invalid, pass nil
  else
    created_at = nil
  end
  # return the parsed value
  return created_at
end