Class: FrequencyConstraint
- Inherits:
-
Object
- Object
- FrequencyConstraint
- Defined in:
- lib/macrohub.rb
Instance Method Summary collapse
- #counter ⇒ Object
- #increment ⇒ Object
-
#initialize(freqx, freq: freqx) ⇒ FrequencyConstraint
constructor
A new instance of FrequencyConstraint.
- #match? ⇒ Boolean
- #reset ⇒ Object
- #to_node ⇒ Object
- #to_rowx ⇒ Object
Constructor Details
#initialize(freqx, freq: freqx) ⇒ FrequencyConstraint
108 109 110 111 112 113 |
# File 'lib/macrohub.rb', line 108 def initialize(freqx, freq: freqx) @freq = freq @counter = 0 @interval = 60 end |
Instance Method Details
#counter ⇒ Object
115 116 117 |
# File 'lib/macrohub.rb', line 115 def counter() @counter end |
#increment ⇒ Object
119 120 121 |
# File 'lib/macrohub.rb', line 119 def increment() @counter += 1 end |
#match? ⇒ Boolean
123 124 125 |
# File 'lib/macrohub.rb', line 123 def match?() @counter < @freq end |
#reset ⇒ Object
127 128 129 130 |
# File 'lib/macrohub.rb', line 127 def reset() puts 'resetting' if $debug @counter = 0 end |
#to_node ⇒ Object
132 133 134 135 |
# File 'lib/macrohub.rb', line 132 def to_node() Rexle::Element.new(:constraint, \ attributes: {type: :frequency, freq: @freq}) end |
#to_rowx ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/macrohub.rb', line 137 def to_rowx() freq = case @freq when 1 'Once' when 2 'Twice' else "Maximum %s times" % @freq end "constraint: %s" % freq end |