Class: CPEE::StateMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/cpee/statemachine.rb

Instance Method Summary collapse

Constructor Details

#initialize(file, readonly, &state) ⇒ StateMachine

Returns a new instance of StateMachine.



18
19
20
21
22
# File 'lib/cpee/statemachine.rb', line 18

def initialize(file,readonly,&state)
  @states = XML::Smart.open_unprotected(file)
  @state = state
  @readonly = readonly
end

Instance Method Details

#readonly?(id) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cpee/statemachine.rb', line 29

def readonly?(id)
  @readonly.include? @state.call(id)
end

#setable?(id, nval) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/cpee/statemachine.rb', line 24

def setable?(id,nval)
  cval = @state.call(id)
  @states.find("/states/setable/#{cval}[#{nval}]").length > 0
end