Class: Fukubukuro::Assignment
- Defined in:
- lib/amber/fukubukuro.rb
Instance Attribute Summary collapse
-
#receiver ⇒ Object
Returns the value of attribute receiver.
-
#statement ⇒ Object
Returns the value of attribute statement.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#receiver ⇒ Object
Returns the value of attribute receiver.
366 367 368 |
# File 'lib/amber/fukubukuro.rb', line 366 def receiver @receiver end |
#statement ⇒ Object
Returns the value of attribute statement.
366 367 368 |
# File 'lib/amber/fukubukuro.rb', line 366 def statement @statement end |
Class Method Details
.new(receiver, statement) ⇒ Object
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
# File 'lib/amber/fukubukuro.rb', line 367 def self.new receiver, statement if receiver.is_a? MethodCall if receiver.meth == :[] index = receiver.args.first MethodCall.new(receiver.object, :[]=, index, statement) elsif receiver.meth == :fuku_send getter = receiver.args.first.value setter = Constant.new(:"#{getter}=") MethodCall.new(receiver.object, :fuku_send, setter, statement) else raise 'Cannot assign to method calls.' end elsif statement.is_a? MethodCall MethodCallAssignment.new receiver, statement.object, statement.meth, *statement.args else assignment = super() do receiver.value = statement.call end assignment.receiver = receiver assignment.statement = statement assignment end end |
Instance Method Details
#inspect ⇒ Object
390 391 392 |
# File 'lib/amber/fukubukuro.rb', line 390 def inspect 'Assignment(%p = %p)' % [receiver, statement] end |
#pretty_print(q) ⇒ Object
393 394 395 396 397 398 399 |
# File 'lib/amber/fukubukuro.rb', line 393 def pretty_print q q.group 2, 'Assignment(', ')' do q.pp receiver q.text ' = ' q.pp statement end end |