Skip to content

Commit

Permalink
Adding an API method to return a boolean whether any of the deadpoole…
Browse files Browse the repository at this point in the history
…d fields have values. The current deadpooled method returns nil if any of the fields are nil.
  • Loading branch information
Daniela Wellisz and Jeremiah Lee authored and tylercunnion committed Nov 30, 2013
1 parent 57402c2 commit baa2741
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/crunchbase/company.rb
Expand Up @@ -79,6 +79,11 @@ def founded
@founded ||= date_from_components(@founded_year, @founded_month, @founded_day)
end

# Returns whether the company has a deadpooled date component
def deadpooled?
@deadpooled ||= @deadpooled_year || @deadpooled_month || @deadpooled_day
end

# Returns the date the company was deadpooled, or nil if not provided.
def deadpooled
@deadpooled ||= date_from_components(@deadpooled_year, @deadpooled_month, @deadpooled_day)
Expand Down
7 changes: 7 additions & 0 deletions spec/crunchbase/company_spec.rb
Expand Up @@ -27,6 +27,13 @@ module Crunchbase
company.deadpooled.should === Date.new(2004, 2, 1)
end

it "should return whether the company was deadpooled" do
company = Company.new({"deadpooled_year" => 2004,
"created_at" => "Sat Dec 22 08:42:28 UTC 2007",
"updated_at" => "Sat Dec 22 08:42:28 UTC 2007"})
company.deadpooled?.should be_true
end

it "should get a complete list" do
all_companies = Company.all
all_companies[0].entity.name.should == all_companies[0].name
Expand Down

0 comments on commit baa2741

Please sign in to comment.