In both examples clients of the StateExample class call its transition() method with a criteria parameter to change it's state.
Java implementationThe StateExample class has a reference to an implementation of the IState interface. The transition() method delegates itself to the evaluate() method of the IState implementation which evaluates the criteria and returns either itself or a new IState implementation. Basically this allows the Implementation of the State to be abstracted to the interface IState and the StateExample class works on the contract specified by IState.
Ruby ImplementationLet's now look at the Ruby implementation of the same example. The StateExample class looks almost similar to it's Java counterpart. What's noticeable here is the absence of the equivalent of interface IState.
Duck typing in Ruby allows this. The object referenced by the current_state variable only needs to contain an evaluate() method. The contract is therefore on the behaviour of the value of current_state rather than it's type.