That’s where blocks come in, to simplify the definition and use of these buttons making maintenance simpler so we could call the specific block to which we pass on the necessary parameters or methods to attain the final outcome. Below is an example of how this can be achieved with blocks creating a class called devicebutton:
class DeviceButton < Button
def initialize(label, &process)
super(label)
@action = action
end
def buttonSelected
@action.call(self)
end
end
bPlay = DeviceButton.new(“Play”) {cdList.play}
bPause = DeviceButton.new(“Pause”) {cdList.pause}
