Class: Mind

Inherits:
Object
  • Object
show all
Defined in:
lib/Olib/character/mind.rb

Constant Summary collapse

@@states =
OpenStruct.new(
  :saturated        => "saturated",
  :must_rest        => "must rest",
  :numbed           => "numbed",
  :becoming_numbed  => "becoming numbed",
  :muddled          => "muddled",
  :clear            => "clear",
  :fresh_and_clear  => "fresh and clear",
  :clear_as_a_bell  => "clear as a bell"
)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.percentObject

Returns Fixnum.

Returns:

  • Fixnum



35
36
37
# File 'lib/Olib/character/mind.rb', line 35

def Mind.percent
  percentmind
end

.stateObject

Returns String.

Returns:

  • String



27
28
29
# File 'lib/Olib/character/mind.rb', line 27

def Mind.state
  checkmind
end

.statesObject

Returns OpenStruct.

Returns:

  • OpenStruct



19
20
21
# File 'lib/Olib/character/mind.rb', line 19

def Mind.states
  @@states
end

Instance Method Details

#nameObject

dynamically defines all methods to check state

Example:

Mind.saturated?
Mind.must_rest?


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/Olib/character/mind.rb', line 45

Mind.states.each_pair { |name, str|
  Mind.define_singleton_method((name.to_s + "?").to_sym) do
    Mind.state.eql?(str)
  end

  Mind.define_singleton_method("while_#{name.to_s}".to_sym) do
    wait_while("waiting while mind / %s" % str) { 
      Mind.state.eql? str
    }
  end

  Mind.define_singleton_method("until_#{name.to_s}".to_sym) do
    wait_until("waiting until mind / %s" % str) { 
      Mind.state.eql?(str)
    }
  end
}