# Highline and Chronic

**URL:** <https://www.ruby-forum.com/t/highline-and-chronic/193162>\
**Category:** Ruby\
**Created:** [August 12, 2010, 9:42am UTC](https://www.ruby-forum.com/t/highline-and-chronic/193162 "2010-08-12T09:42:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sentinel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sentinel](https://www.ruby-forum.com/u/sentinel)\
**Post date:** [August 12, 2010, 9:42am UTC](https://www.ruby-forum.com/t/highline-and-chronic/193162/1 "2010-08-12T09:42:45Z")

</div>

I just heard of Chronic and wanted to integrate it with Highline so i  
could get natural language dates like “yesterday”, “tomorrow” etc.

I find that I get a nil returned if I do:

dob1 = ask("DOB? ", Chronic)

However, if i try this it works:

class NameClass  
def self.parse( string )  
Chronic.parse(string)  
end

end

dob = ask("Date? ", NameClass)

Looking thru source reveals that :

```
  elsif [Date, DateTime].include?(@answer_type) or

```

@answer\_type.is\_a?(Class)  
@answer\_type.parse(answer\_string)

Now Chronic is a module not a class. So i guess in this case no part of  
the “case” was called.  
Now my question is:

1. Should there be a respond\_to in the Highline case, or perhaps a check  
for module also ?

2. Is there anyway i can do this in one line without modifying highline,  
and without creating a separate class. Is there some block method or  
param i could use to invoke Chronic.parse ?

thanks.

---

<div class="post-metadata">

**Author:** ![sentinel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sentinel](https://www.ruby-forum.com/u/sentinel)\
**Post date:** [August 13, 2010, 2:20am UTC](https://www.ruby-forum.com/t/highline-and-chronic/193162/2 "2010-08-13T02:20:37Z")

</div>

On Aug 12, 2010, at 2:42 AM, R… Kumar 1.9.1 OSX wrote:

> 1. Should there be a respond\_to in the Highline case, or perhaps a check  
> for module also ?

That may be a better approach. If you have the time, fork the project  
on Github and work out a patch for it so we can see how that looks.

James Edward G. II

---

<div class="post-metadata">

**Author:** ![sentinel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sentinel](https://www.ruby-forum.com/u/sentinel)\
**Post date:** [August 13, 2010, 12:11am UTC](https://www.ruby-forum.com/t/highline-and-chronic/193162/3 "2010-08-13T00:11:10Z")

</div>

On Thu, Aug 12, 2010 at 2:42 AM, R… Kumar 1.9.1 OSX  
\<removed\_email\_address@domain.invalid

> wrote:

> def self.parse( string )  
> @answer\_type.is\_a?(Class)  
> param i could use to invoke Chronic.parse ?

You could use a proc object

# test.rb

require ‘rubygems’  
require ‘highline’  
require ‘chronic’

hl = HighLine.new

dob1 = hl.ask("DOB? ", proc{|x| Chronic.parse(x)} )

p dob1

#######

> ruby test.rb  
> DOB? Last Tuesday  
> Tue Aug 10 12:00:00 -0500 2010
