Class: Ruleby::Steel::RuleBuilder
- Inherits:
-
Object
- Object
- Ruleby::Steel::RuleBuilder
- Defined in:
- lib/dsl/steel.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
- #then=(action) ⇒ Object
- #when {|wb| ... } ⇒ Object
- #when=(pattern) ⇒ Object
Constructor Details
#initialize(name, pattern = nil, action = nil, priority = 0) ⇒ RuleBuilder
Returns a new instance of RuleBuilder.
35 36 37 38 39 40 |
# File 'lib/dsl/steel.rb', line 35 def initialize(name, pattern=nil, action=nil, priority=0) @name = name @pattern = pattern @action = action @priority = priority end |
Instance Method Details
#build_rule ⇒ Object
73 74 75 |
# File 'lib/dsl/steel.rb', line 73 def build_rule r = Ruleby::Core::Rule.new @name, @pattern, @action, @priority end |
#priority ⇒ Object
64 65 66 |
# File 'lib/dsl/steel.rb', line 64 def priority return @priority end |
#priority=(p) ⇒ Object
68 69 70 71 |
# File 'lib/dsl/steel.rb', line 68 def priority=(p) @priority = p @action.priority = @priority end |
#then(&block) ⇒ Object
48 49 50 51 52 |
# File 'lib/dsl/steel.rb', line 48 def then(&block) @action = Core::Action.new(&block) @action.name = @name @action.priority = @priority end |
#then=(action) ⇒ Object
58 59 60 61 62 |
# File 'lib/dsl/steel.rb', line 58 def then=(action) @action = action @action.name = @name @action.priority = @priority end |
#when {|wb| ... } ⇒ Object
42 43 44 45 46 |
# File 'lib/dsl/steel.rb', line 42 def when(&block) wb = WhenBuilder.new yield wb @pattern = wb.pattern end |
#when=(pattern) ⇒ Object
54 55 56 |
# File 'lib/dsl/steel.rb', line 54 def when=(pattern) @pattern = pattern end |