class Juncture
Constants
- DATE
- VERSION
Public Class Methods
new(*states, **kwargs)
click to toggle source
# File lib/juncture.rb, line 2 def initialize *states, **kwargs @states = states @current_state = kwargs[:default] end
Public Instance Methods
<(value)
click to toggle source
# File lib/juncture.rb, line 45 def <(value) index < @states.index(value) end
<=(value)
click to toggle source
# File lib/juncture.rb, line 49 def <=(value) index <= @states.index(value) end
==(value)
click to toggle source
# File lib/juncture.rb, line 37 def ==(value) @current_state == value end
===(value)
click to toggle source
# File lib/juncture.rb, line 41 def ===(value) @current_state === value end
>(value)
click to toggle source
# File lib/juncture.rb, line 53 def >(value) index > @states.index(value) end
>=(value)
click to toggle source
# File lib/juncture.rb, line 57 def >=(value) index >= @states.index(value) end
inspect()
click to toggle source
# File lib/juncture.rb, line 15 def inspect "#<Juncture:%s State:%s>" % [(object_id << 1).to_s(16), @current_state] end
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
# File lib/juncture.rb, line 7 def method_missing meth, *args, &block if @states.respond_to? meth @states.send meth, *args, &block else super end end
next()
click to toggle source
# File lib/juncture.rb, line 29 def next if index.nil? || @states[index+1].nil? @current_state = @states[0] else @current_state = @states[index+1] end end
set(new_state)
click to toggle source
# File lib/juncture.rb, line 23 def set(new_state) raise "UNKNOWN STATE: %s" % new_state unless @states.include? new_state @current_state = new_state end
Also aliased as: is
state()
click to toggle source
# File lib/juncture.rb, line 19 def state @current_state end
Private Instance Methods
index()
click to toggle source
# File lib/juncture.rb, line 63 def index @states.index(@current_state) end