Created
January 9, 2012 21:52
-
-
Save wapcaplet/1585154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Return true if we're inside a conditional block, false otherwise. | |
# | |
def in_conditional? | |
return @conditional_stack.length > 1 | |
end | |
# Return true if we're inside a true conditional block (one that | |
# evaluated true and should be executed). | |
# | |
def in_true_conditional? | |
return in_conditional? && @conditional_stack.last == true | |
end | |
# Return true if we're inside a false conditional block (one that | |
# evaluated false and should not be executed). | |
# | |
def in_false_conditional? | |
return in_conditional? && @conditional_stack.last == false | |
end | |
# Return true if we're inside a nil conditional block (one whose evaluation | |
# doesn't matter because it was precluded by an outer conditional block | |
# that was false) | |
# | |
def in_nil_conditional? | |
return in_conditional? && @conditional_stack.last == nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment