Class: DrgDSL::Ast::Expression
- Inherits:
-
Object
- Object
- DrgDSL::Ast::Expression
- Includes:
- Node
- Defined in:
- lib/drgdsl/ast.rb
Overview
Represents a list of expressions joined with an “OR”, e.g., “exp1 or exp2 or exp3 …”
Instance Attribute Summary collapse
-
#expressions ⇒ Object
readonly
Returns the value of attribute expressions.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(expressions) ⇒ Expression
constructor
A new instance of Expression.
-
#only_mdc_equality_nodes? ⇒ Boolean
Whether this expression only contains MDC equality checks.
-
#only_sep_equality_nodes? ⇒ Boolean
Whether this expression only contains SEP equality checks.
- #to_hash ⇒ Object
Methods included from Node
#==, #accept, included, #mdc_equality?, node_classes, #pretty_print, #sep_equality?, type, #type
Constructor Details
#initialize(expressions) ⇒ Expression
Returns a new instance of Expression.
82 83 84 |
# File 'lib/drgdsl/ast.rb', line 82 def initialize(expressions) @expressions = expressions end |
Instance Attribute Details
#expressions ⇒ Object (readonly)
Returns the value of attribute expressions.
80 81 82 |
# File 'lib/drgdsl/ast.rb', line 80 def expressions @expressions end |
Instance Method Details
#hash ⇒ Object
102 103 104 |
# File 'lib/drgdsl/ast.rb', line 102 def hash @hash ||= [type, *expressions].hash end |
#only_mdc_equality_nodes? ⇒ Boolean
Returns whether this expression only contains MDC equality checks.
94 95 96 |
# File 'lib/drgdsl/ast.rb', line 94 def only_mdc_equality_nodes? expressions.all?(&:mdc_equality?) end |
#only_sep_equality_nodes? ⇒ Boolean
Returns whether this expression only contains SEP equality checks.
88 89 90 |
# File 'lib/drgdsl/ast.rb', line 88 def only_sep_equality_nodes? expressions.all?(&:sep_equality?) end |
#to_hash ⇒ Object
98 99 100 |
# File 'lib/drgdsl/ast.rb', line 98 def to_hash { or: [expressions.map(&:to_hash)] } end |