Class: Estreet::MemberExpression
- Inherits:
-
Expression
- Object
- Node
- Expression
- Estreet::MemberExpression
- Defined in:
- lib/estreet/member_expression.rb
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(object, property, computed) ⇒ MemberExpression
constructor
A new instance of MemberExpression.
- #to_pattern ⇒ Object
Methods inherited from Expression
#[], #call, coerce, #property, #to_expression, #to_statement
Methods inherited from Node
Constructor Details
#initialize(object, property, computed) ⇒ MemberExpression
Returns a new instance of MemberExpression.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/estreet/member_expression.rb', line 3 def initialize(object, property, computed) @obj = object.to_expression # computed: true is e.g. "object[index]" # computer: false is "object.property" @computed = !!computed @property = if @computed property.to_expression else Identifier.new(property) end end |
Instance Method Details
#attributes ⇒ Object
15 16 17 |
# File 'lib/estreet/member_expression.rb', line 15 def attributes super.merge(object: @obj, property: @property, computed: @computed) end |
#to_pattern ⇒ Object
19 20 21 |
# File 'lib/estreet/member_expression.rb', line 19 def to_pattern self end |