Class: Propose::Tree::Atom

Inherits:
Node
  • Object
show all
Defined in:
lib/propose/tree/atom.rb

Overview

Declarative statement that can be either true or false.

For example: “The sun is shining.”

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#children

Constructor Details

#initialize(name) ⇒ Atom



8
9
10
# File 'lib/propose/tree/atom.rb', line 8

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/propose/tree/atom.rb', line 6

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
# File 'lib/propose/tree/atom.rb', line 12

def ==(other)
  super || @name == other.name
end

#eql?(other) ⇒ Boolean



16
17
18
# File 'lib/propose/tree/atom.rb', line 16

def eql?(other)
  self == other
end

#evaluate(assignment) ⇒ Object



24
25
26
# File 'lib/propose/tree/atom.rb', line 24

def evaluate(assignment)
  assignment[self]
end

#hashObject



20
21
22
# File 'lib/propose/tree/atom.rb', line 20

def hash
  @name.hash
end

#inspectObject



32
33
34
# File 'lib/propose/tree/atom.rb', line 32

def inspect
  "#<Atom #{name}>"
end

#literal?Boolean



28
29
30
# File 'lib/propose/tree/atom.rb', line 28

def literal?
  true
end

#to_sObject



36
37
38
# File 'lib/propose/tree/atom.rb', line 36

def to_s
  name.to_s
end