Class: TimeConstraint

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timex = nil, times: timex, time: timex) ⇒ TimeConstraint

Returns a new instance of TimeConstraint.



158
159
160
161
162
# File 'lib/macrohub.rb', line 158

def initialize(timex=nil, times: timex, time: timex)
  
  @time = times || time
  
end

Instance Attribute Details

#timeObject

Returns the value of attribute time.



156
157
158
# File 'lib/macrohub.rb', line 156

def time
  @time
end

Instance Method Details

#match?(detail) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
167
168
169
170
171
172
173
174
# File 'lib/macrohub.rb', line 164

def match?(detail)
  
  if $debug then
    puts 'inside TimeConstraint#match?' 
    puts 'detail: ' + detail.inspect
    puts '@time: ' + @time.inspect
  end
  
  ChronicBetween.new(@time).within?(detail[:time])
  
end

#to_nodeObject



176
177
178
179
# File 'lib/macrohub.rb', line 176

def to_node()
  Rexle::Element.new(:constraint, \
                      attributes: {type: :time, time: @time})      
end

#to_rowxObject



181
182
183
# File 'lib/macrohub.rb', line 181

def to_rowx()            
  "constraint: %s" %  @time
end