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

Returns a new instance of 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

#evaluate(assignment) ⇒ Object



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

def evaluate(assignment)
  assignment[self]
end

#inspectObject



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

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

#literal?Boolean

Returns:

  • (Boolean)


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

def literal?
  true
end

#to_sObject



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

def to_s
  name.to_s
end