synewaves/rubillow — pull request #21 by danielberkompas (2013-04-10 18:55:39+00:00)
Title: Fix rent zestimate when <valueChange> doesn't have a duration attribute

Zillow typically returns a rentzestimate in this format:

``` xml

2505
04/01/2013

50

1979
3056

```

However, sometimes `` doesn't have a `duration` attribute.

``` xml

```

This was causing Rubillow to throw an error like the following for me:

> NoMethodError: undefined method `value' for nil:NilClass - Zestimateable#extract_zestimate:71

The offending line in Rubillow looked like this:

``` ruby
:value_duration => xml.xpath('//rentzestimate/valueChange').attr('duration').value.chomp
```

The duration attribute is nil, so this raised an error. Fixed it with this:

``` ruby
:value_duration => xml.xpath('//rentzestimate').first.xpath("//valueChange").first.attr("duration").chomp
```

I added a test to verify that this fixes the issue, and also **bumped the version number to 0.0.6.** Since this is a patch, I think [SemVer](http://semver.org/) would require a new version number.

**P.S.** Why are we calling [String#chomp](http://ruby-doc.org/core-2.0/String.html#chomp-method) on the end here? It was already there so I left it in, but it seems unnecessary to me.