Class: Literal

Inherits:
Object
  • Object
show all
Defined in:
lib/logical/formulas/literal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(letter) ⇒ Literal

Returns a new instance of Literal.



6
7
8
# File 'lib/logical/formulas/literal.rb', line 6

def initialize(letter)
  @letter = letter
end

Instance Attribute Details

#letterObject (readonly)

Returns the value of attribute letter.



4
5
6
# File 'lib/logical/formulas/literal.rb', line 4

def letter
  @letter
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/logical/formulas/literal.rb', line 22

def ==(other)
  other.class == Literal && other.letter == letter
end

#evaluate(interpretation) ⇒ Object



10
11
12
# File 'lib/logical/formulas/literal.rb', line 10

def evaluate(interpretation)
  interpretation.evaluate(@letter)
end

#literalsObject



18
19
20
# File 'lib/logical/formulas/literal.rb', line 18

def literals
  Set[self]
end

#to_sObject



14
15
16
# File 'lib/logical/formulas/literal.rb', line 14

def to_s
  @letter
end