Class: Fukubukuro::MethodCallAssignment
- Defined in:
- lib/amber/fukubukuro.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#meth ⇒ Object
Returns the value of attribute meth.
-
#object ⇒ Object
Returns the value of attribute object.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
556 557 558 |
# File 'lib/amber/fukubukuro.rb', line 556 def args @args end |
#meth ⇒ Object
Returns the value of attribute meth.
556 557 558 |
# File 'lib/amber/fukubukuro.rb', line 556 def meth @meth end |
#object ⇒ Object
Returns the value of attribute object.
556 557 558 |
# File 'lib/amber/fukubukuro.rb', line 556 def object @object end |
#receiver ⇒ Object
Returns the value of attribute receiver.
556 557 558 |
# File 'lib/amber/fukubukuro.rb', line 556 def receiver @receiver end |
Class Method Details
.new(receiver, object, meth, *args) ⇒ Object
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/amber/fukubukuro.rb', line 557 def self.new receiver, object, meth, *args method_call_assignment = if args.empty? super() do receiver.value = object.value.send meth end elsif args.all? { |arg| arg.is_a? Constant } if args.size == 1 value = args.first.value super() do receiver.value = object.value.send meth, value end else raise args = args.map(&:value) super() do receiver.value = object.value.send meth, *args end end else if args.size == 1 arg = args.first super() do receiver.value = object.value.send meth, arg.value end else super() do receiver.value = object.value.send meth, *args.map { |a| a.value } end end end method_call_assignment.receiver = receiver method_call_assignment.object = object method_call_assignment.meth = meth method_call_assignment.args = args method_call_assignment end |
Instance Method Details
#inspect ⇒ Object
594 595 596 |
# File 'lib/amber/fukubukuro.rb', line 594 def inspect 'MethodCallAssignment(%p = %p.%p(%p))' % [receiver, object, meth, args] end |
#pretty_print(q) ⇒ Object
597 598 599 600 601 602 603 604 605 606 607 608 |
# File 'lib/amber/fukubukuro.rb', line 597 def pretty_print q q.group 2, 'MethodCallAssignment(', ')' do q.pp receiver q.text ' = ' q.pp object q.text '.' q.pp meth q.group 2, '(', ')' do q.pp args end end end |