Add RuleSet#could_be_empty?
This commit is contained in:
parent
291509f005
commit
0f1c00d1a6
@ -2,17 +2,41 @@ class Propane
|
||||
|
||||
class RuleSet
|
||||
|
||||
# @return [String]
|
||||
# Name of the RuleSet.
|
||||
attr_reader :name
|
||||
|
||||
# @return [Array<Rule>]
|
||||
# Rules in the RuleSet.
|
||||
attr_reader :rules
|
||||
|
||||
# Construct a RuleSet.
|
||||
#
|
||||
# @param name [String]
|
||||
# Name of the RuleSet.
|
||||
def initialize(name)
|
||||
@name = name
|
||||
@rules = []
|
||||
@could_be_empty = false
|
||||
end
|
||||
|
||||
# Add a Rule to the RuleSet.
|
||||
#
|
||||
# @param rule [Rule]
|
||||
# Rule to add.
|
||||
def <<(rule)
|
||||
@rules << rule
|
||||
if rule.empty?
|
||||
@could_be_empty = true
|
||||
end
|
||||
end
|
||||
|
||||
# Return whether any Rule in the RuleSet is empty.
|
||||
#
|
||||
# @return [Boolean]
|
||||
# Whether any rule in the RuleSet is empty.
|
||||
def could_be_empty?
|
||||
@could_be_empty
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user