Class: Propose::Tree::Atom
Overview
Declarative statement that can be either true or false.
For example: “The sun is shining.”
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #evaluate(assignment) ⇒ Object
- #hash ⇒ Object
-
#initialize(name) ⇒ Atom
constructor
A new instance of Atom.
- #inspect ⇒ Object
- #literal? ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from Node
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
#name ⇒ Object (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 |
#hash ⇒ Object
20 21 22 |
# File 'lib/propose/tree/atom.rb', line 20 def hash @name.hash end |
#inspect ⇒ Object
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_s ⇒ Object
36 37 38 |
# File 'lib/propose/tree/atom.rb', line 36 def to_s name.to_s end |