Class: MiniKraken::Atomic::AtomicTerm
- Inherits:
-
Core::Term
- Object
- Core::BaseTerm
- Core::Term
- MiniKraken::Atomic::AtomicTerm
- Defined in:
- lib/mini_kraken/atomic/atomic_term.rb
Overview
An atomic term is an elementary MiniKraken term, a data value that cannot be decomposed into simpler MiniKraken term(s). Typically, an atomic term encapsulates a Ruby primitive data object. MiniKraken treats atomic terms as immutable objects.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Internal representation of a MiniKraken data value.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Data equality testing.
-
#dependencies(_ctx) ⇒ Set
Return the list of variable (i_names) that this term depends on.
-
#dup_cond(_substitutions) ⇒ Term
Make a copy of self with all the variable reference being replaced by the corresponding value in the Hash.
-
#eql?(other) ⇒ Boolean
Type and data equality testing.
-
#floating?(_ctx) ⇒ FalseClass
An atomic term has a definite value, therefore it is not floating.
-
#initialize(aValue) ⇒ AtomicTerm
constructor
Initialize an atomic term with the given data object.
-
#pinned?(_ctx) ⇒ TrueClass
An atomic term is a pinned term: by definition, it has a definite value.
-
#quote(_ctx) ⇒ AtomicTerm
Treat this object as a data value.
-
#to_s ⇒ String
Return a String representation of the atomic term.
-
#unbound?(_ctx) ⇒ FalseClass
An atomic term, by definition is bound to a definite value.
Constructor Details
#initialize(aValue) ⇒ AtomicTerm
Initialize an atomic term with the given data object.
21 22 23 24 25 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 21 def initialize(aValue) super() @value = aValue @value.freeze end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns Internal representation of a MiniKraken data value.
17 18 19 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 17 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
Data equality testing
64 65 66 67 68 69 70 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 64 def ==(other) if other.respond_to?(:value) value == other.value else value == other end end |
#dependencies(_ctx) ⇒ Set
Return the list of variable (i_names) that this term depends on. For atomic terms, there is no such dependencies.
83 84 85 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 83 def dependencies(_ctx) Set.new end |
#dup_cond(_substitutions) ⇒ Term
Make a copy of self with all the variable reference being replaced by the corresponding value in the Hash.
91 92 93 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 91 def dup_cond(_substitutions) dup end |
#eql?(other) ⇒ Boolean
Type and data equality testing
75 76 77 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 75 def eql?(other) (self.class == other.class) && value.eql?(other.value) end |
#floating?(_ctx) ⇒ FalseClass
An atomic term has a definite value, therefore it is not floating.
37 38 39 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 37 def floating?(_ctx) false end |
#pinned?(_ctx) ⇒ TrueClass
An atomic term is a pinned term: by definition, it has a definite value.
45 46 47 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 45 def pinned?(_ctx) true end |
#quote(_ctx) ⇒ AtomicTerm
Treat this object as a data value.
57 58 59 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 57 def quote(_ctx) self end |
#to_s ⇒ String
Return a String representation of the atomic term
51 52 53 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 51 def to_s value.to_s end |
#unbound?(_ctx) ⇒ FalseClass
An atomic term, by definition is bound to a definite value.
30 31 32 |
# File 'lib/mini_kraken/atomic/atomic_term.rb', line 30 def unbound?(_ctx) false end |