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.
-
.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 |
.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
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 } |