Twiddr
Twiddr

Reputation: 297

Multiple boolean functions

I got these 2 boolean functions:

 def settled?
    self.settled == true
 end

 def negative_pl?
    self.profitloss < 0
 end

How can I test for both of them at the same time? I want to do something like this in my view:

<%= 'classRed' if bet.settled?.negative_pl? %>

I know the above don't work, but the best way to explain what I want to do :)

Thanks!

Upvotes: 0

Views: 163

Answers (2)

Deradon
Deradon

Reputation: 1787

<%= 'classRed' if bet.settled? and bet.negative_pl? %>

Upvotes: 1

Chris Heald
Chris Heald

Reputation: 62648

You need a clause per check:

if bet.settled? and bet.negative_pl?

Upvotes: 1

Related Questions