Module: Predicate::Literal

Includes:
Expr
Defined in:
lib/predicate/nodes/literal.rb

Constant Summary

Constants included from Expr

Expr::OP_NEGATIONS

Instance Method Summary collapse

Methods included from Expr

#!, #&, #and_split, #attr_split, #bind, #constant_variables, #constants, #contradiction?, #dyadic_priority, #identifier?, #literal?, #opaque?, #qualify, #rename, #sexpr, #tautology?, #to_hash, #to_s, #to_sequel, #unqualify, #|

Methods included from Factory

#and, #between, #comp, #contradiction, #from_hash, #identifier, #in, #intersect, #literal, #match, #native, #not, #opaque, #or, #placeholder, #qualified_identifier, #tautology

Instance Method Details

#empty_value?Boolean

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/predicate/nodes/literal.rb', line 21

def empty_value?
  return false if has_placeholder?
  value.respond_to?(:empty?) && value.empty?
end

#evaluate(tuple) ⇒ Object

Raises:



31
32
33
34
# File 'lib/predicate/nodes/literal.rb', line 31

def evaluate(tuple)
  raise UnboundError if has_placeholder?
  value
end

#free_variablesObject



9
10
11
# File 'lib/predicate/nodes/literal.rb', line 9

def free_variables
  @free_variables ||= []
end

#has_placeholder?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/predicate/nodes/literal.rb', line 17

def has_placeholder?
  value.is_a?(Placeholder)
end

#priorityObject



5
6
7
# File 'lib/predicate/nodes/literal.rb', line 5

def priority
  100
end

#singleton_value?Boolean

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/predicate/nodes/literal.rb', line 26

def singleton_value?
  return false if has_placeholder?
  value.respond_to?(:size) && value.size == 1
end

#valueObject



13
14
15
# File 'lib/predicate/nodes/literal.rb', line 13

def value
  last
end