Class: Mind
- Inherits:
-
Object
- Object
- Mind
- 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
-
.percent ⇒ Object
Fixnum.
-
.rest!(state = Mind.states.saturated) ⇒ Object
Nil.
-
.state ⇒ Object
String.
-
.states ⇒ Object
OpenStruct.
Instance Method Summary collapse
-
#name ⇒ Object
dynamically defines all methods to check state.
Class Method Details
.percent ⇒ Object
Returns Fixnum.
35 36 37 |
# File 'lib/Olib/character/mind.rb', line 35 def Mind.percent percentmind end |
.rest!(state = Mind.states.saturated) ⇒ Object
Returns nil.
66 67 68 69 |
# File 'lib/Olib/character/mind.rb', line 66 def Mind.rest!(state=Mind.states.saturated) Go2.origin wait_until { Mind.state != state } end |
.state ⇒ Object
Returns String.
27 28 29 |
# File 'lib/Olib/character/mind.rb', line 27 def Mind.state checkmind end |
.states ⇒ Object
Returns OpenStruct.
19 20 21 |
# File 'lib/Olib/character/mind.rb', line 19 def Mind.states @@states end |
Instance Method Details
#name ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 == str end Mind.define_singleton_method("until_not_#{name.to_s}".to_sym) do wait_until { Mind.state != str } end Mind.define_singleton_method("until_#{name.to_s}".to_sym) do wait_until { Mind.state == str } end } |