The method defined in a different class and I don't understand how methods are associated with each other
attr_reader :stations #getter method
attr_accessor :route #getter and setter method
route.stations # How it works?
route = Route.new
train = Train.new
train.route = route
When a method call has an explicit receiver, it doesn't matter in what context you call it from. All that matters is that the receiver has that method.
The context of method call
route.stations does not matter. All that matters is whether the receiver
route has the method
route is a
Route instance, it does have the method
stations, as defined by