Class: Ruleby::Steel::RuleBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/steel.rb

Instance Method Summary collapse

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_ruleObject



73
74
75
# File 'lib/dsl/steel.rb', line 73

def build_rule
  r = Ruleby::Core::Rule.new @name, @pattern, @action, @priority
end

#priorityObject



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

Yields:

  • (wb)


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