Class: Ducktape::Expression::IndexerExp
- Inherits:
-
Object
- Object
- Ducktape::Expression::IndexerExp
- Includes:
- BinaryOpExp, Ref
- Defined in:
- lib/ducktape/expression/indexer_exp.rb
Overview
Instance Attribute Summary
Attributes included from BinaryOpExp
Instance Method Summary collapse
- #bind(src, type, qual = nil, root = src) ⇒ Object
- #call(parms) ⇒ Object
- #owner=(o) ⇒ Object
- #rightmost ⇒ Object
- #unbind ⇒ Object
- #unparse ⇒ Object
- #value ⇒ Object
- #value=(v) ⇒ Object
Methods included from BinaryOpExp
Instance Method Details
#bind(src, type, qual = nil, root = src) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 9 def bind(src, type, qual = nil, root = src) unbind src = left.bind(src, :path, qual, root) @source = WeakReference.new(src) @type = type params.each { |param| param.bind(root, :path) } src.on_store(self) if src.is_a?(Hookable) && src.respond_to?(:on_store) #convention hook for []= value end |
#call(parms) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 33 def call(parms) parms = parms.args.dup parms.pop return unless parms == params_values owner.send("#{@type}_changed") end |
#owner=(o) ⇒ Object
40 41 42 43 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 40 def owner=(o) @owner, left.owner = o, o params.each { |param| param.owner = o } end |
#rightmost ⇒ Object
45 46 47 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 45 def rightmost self end |
#unbind ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 21 def unbind params.each { |param| param.unbind } return unless @source src = @source.object return @source, @type, @qual = nil unless src src = source src.remove_hook(:on_store, self) if src.is_a?(Hookable) && src.respond_to?(:on_store) nil end |
#unparse ⇒ Object
49 50 51 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 49 def unparse "#{left.unparse}[#{params.map(&:unparse).join(',')}]" end |
#value ⇒ Object
53 54 55 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 53 def value source[*params_values] end |
#value=(v) ⇒ Object
57 58 59 |
# File 'lib/ducktape/expression/indexer_exp.rb', line 57 def value=(v) source[*params_values] = v end |