Class: TaskJuggler::LogicalFlag
- Inherits:
-
LogicalOperation
- Object
- LogicalOperation
- TaskJuggler::LogicalFlag
- Defined in:
- lib/taskjuggler/LogicalOperation.rb
Overview
This class handles operands that represent flags. The operation evaluates to true if the property provided by the expression has the flag assigned.
Instance Attribute Summary
Attributes inherited from LogicalOperation
#operand1, #operand2, #operator
Instance Method Summary collapse
-
#eval(expr) ⇒ Object
Return true if the property has the flag assigned.
-
#initialize(opnd) ⇒ LogicalFlag
constructor
A new instance of LogicalFlag.
- #to_s(query) ⇒ Object
Constructor Details
#initialize(opnd) ⇒ LogicalFlag
Returns a new instance of LogicalFlag.
234 235 236 |
# File 'lib/taskjuggler/LogicalOperation.rb', line 234 def initialize(opnd) super end |
Instance Method Details
#eval(expr) ⇒ Object
Return true if the property has the flag assigned.
239 240 241 242 243 244 245 246 247 |
# File 'lib/taskjuggler/LogicalOperation.rb', line 239 def eval(expr) if expr.query.is_a?(Query) # This is used for Project or PTN related Queries expr.query.property['flags', 0].include?(@operand1) else # This is used for Journal objects. expr.query.flags.include?(@operand1) end end |
#to_s(query) ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/taskjuggler/LogicalOperation.rb', line 249 def to_s(query) if query if query.is_a?(Query) query.property['flags', 0].include?(@operand1) ? 'true' : 'false' else query.flags.include?(@operand1) ? 'true' : 'false' end else @operand1 end end |