Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
Created May 25, 2011 04:39
Show Gist options
  • Save ryanbriones/990345 to your computer and use it in GitHub Desktop.
Save ryanbriones/990345 to your computer and use it in GitHub Desktop.
class Foo
def deadline_string=(deadline_string)
self.deadline = (parse_string(deadline_string, Chronic) || parse_string(deadline_string, Time))
@deadline_invalid = true unless self.deadline
end
private
def parse_string(string, parser)
begin
parser.parse(string)
rescue
end
end
end
@carlthuringer
Copy link

That's good, but what about setting an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment