Class: Skeem::SkmCompoundDatum
- Inherits:
-
SkmElement
- Object
- Struct
- SkmElement
- Skeem::SkmCompoundDatum
- Extended by:
- Forwardable
- Defined in:
- lib/skeem/skm_compound_datum.rb
Overview
Abstract class.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#members ⇒ Object
(also: #children, #to_a)
Returns the value of attribute members.
Attributes inherited from SkmElement
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #skm_equal?)
-
#accept(aVisitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
- #evaluate(aRuntime) ⇒ Object
-
#initialize(theMembers) ⇒ SkmCompoundDatum
constructor
A new instance of SkmCompoundDatum.
-
#quasiquote(aRuntime) ⇒ Object
Return this object un-evaluated.
- #quoted! ⇒ Object
- #unquoted! ⇒ Object
- #verbatim? ⇒ Boolean
Methods inherited from SkmElement
#boolean?, #bound!, #callable?, #char?, #complex?, #done!, #inspect, #integer?, #list?, #null?, #number?, #pair?, #procedure?, #rational?, #real?, #skm_eq?, #string?, #symbol?, #vector?
Constructor Details
#initialize(theMembers) ⇒ SkmCompoundDatum
Returns a new instance of SkmCompoundDatum.
17 18 19 20 |
# File 'lib/skeem/skm_compound_datum.rb', line 17 def initialize(theMembers) super(nil) @members = theMembers.nil? ? [] : theMembers end |
Instance Attribute Details
#members ⇒ Object Also known as: children, to_a
Returns the value of attribute members.
11 12 13 |
# File 'lib/skeem/skm_compound_datum.rb', line 11 def members @members end |
Instance Method Details
#==(other) ⇒ Object Also known as: skm_equal?
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/skeem/skm_compound_datum.rb', line 22 def ==(other) return true if equal?(other) case other when SkmCompoundDatum self.class == other.class && members == other.members when Array members == other end end |
#accept(aVisitor) ⇒ Object
Part of the 'visitee' role in Visitor design pattern.
64 65 66 |
# File 'lib/skeem/skm_compound_datum.rb', line 64 def accept(aVisitor) aVisitor.visit_compound_datum(self) end |
#evaluate(aRuntime) ⇒ Object
41 42 43 44 |
# File 'lib/skeem/skm_compound_datum.rb', line 41 def evaluate(aRuntime) members_eval = members.map { |elem| elem.evaluate(aRuntime) } self.class.new(members_eval) end |
#quasiquote(aRuntime) ⇒ Object
Return this object un-evaluated. Reminder: As terminals are atomic, there is no need to launch a visitor.
49 50 51 52 |
# File 'lib/skeem/skm_compound_datum.rb', line 49 def quasiquote(aRuntime) quasi_members = members.map { |elem| elem.quasiquote(aRuntime) } self.class.new(quasi_members) end |
#quoted! ⇒ Object
54 55 56 |
# File 'lib/skeem/skm_compound_datum.rb', line 54 def quoted! members.each(&:quoted!) end |
#unquoted! ⇒ Object
58 59 60 |
# File 'lib/skeem/skm_compound_datum.rb', line 58 def unquoted! members.each(&:unquoted!) end |
#verbatim? ⇒ Boolean
36 37 38 39 |
# File 'lib/skeem/skm_compound_datum.rb', line 36 def verbatim? found = members.find_index { |elem| !elem.verbatim? } found ? false : true end |