Class: Ruleby::LeTigre::RuleBuilder
- Inherits:
-
Object
- Object
- Ruleby::LeTigre::RuleBuilder
- Defined in:
- lib/dsl/letigre.rb
Instance Method Summary collapse
- #build_rule ⇒ Object
-
#initialize(name, pattern = nil, action = nil, priority = 0) ⇒ RuleBuilder
constructor
A new instance of RuleBuilder.
- #priority ⇒ Object
- #priority=(p) ⇒ Object
- #then(&block) ⇒ Object
- #when(pattern) ⇒ Object
Constructor Details
#initialize(name, pattern = nil, action = nil, priority = 0) ⇒ RuleBuilder
Returns a new instance of RuleBuilder.
46 47 48 49 50 51 52 53 54 |
# File 'lib/dsl/letigre.rb', line 46 def initialize(name, pattern=nil, action=nil, priority=0) @name = name @pattern = pattern @action = action @priority = priority @tags = {} @when_counter = 0 end |
Instance Method Details
#build_rule ⇒ Object
75 76 77 |
# File 'lib/dsl/letigre.rb', line 75 def build_rule Core::Rule.new @name, @pattern, @action, @priority end |
#priority ⇒ Object
66 67 68 |
# File 'lib/dsl/letigre.rb', line 66 def priority return @priority end |
#priority=(p) ⇒ Object
70 71 72 73 |
# File 'lib/dsl/letigre.rb', line 70 def priority=(p) @priority = p @action.priority = @priority end |
#then(&block) ⇒ Object
60 61 62 63 64 |
# File 'lib/dsl/letigre.rb', line 60 def then(&block) @action = Core::Action.new(&block) @action.name = @name @action.priority = @priority end |
#when(pattern) ⇒ Object
56 57 58 |
# File 'lib/dsl/letigre.rb', line 56 def when(pattern) @pattern = pattern end |