Class: GamesAndRpgParadise::Mud::Character
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Mud::Character
- Defined in:
- lib/games_and_rpg_paradise/mud/character/character.rb
Overview
RpgParadise::Mud::Character
Instance Attribute Summary collapse
-
#age ⇒ Object
(also: #age?)
Returns the value of attribute age.
-
#character_name ⇒ Object
(also: #character_name?, #name?, #name)
Returns the value of attribute character_name.
-
#gender ⇒ Object
(also: #gender?)
Returns the value of attribute gender.
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === GamesAndRpgParadise::Mud::Characters[] ========================================================================= #.
-
.load(file_or_hash) ⇒ Object
# === GamesAndRpgParadise::Mud::Character.load.
Instance Method Summary collapse
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ Character
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ Character
#
initialize
#
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 32 def initialize( commandline_arguments = nil, run_already = true ) reset # set_commandline_arguments( # commandline_arguments # ) run if run_already end |
Instance Attribute Details
#age ⇒ Object Also known as: age?
Returns the value of attribute age.
26 27 28 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 26 def age @age end |
#character_name ⇒ Object Also known as: character_name?, name?, name
Returns the value of attribute character_name.
20 21 22 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 20 def character_name @character_name end |
#gender ⇒ Object Also known as: gender?
Returns the value of attribute gender.
24 25 26 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 24 def gender @gender end |
Class Method Details
.[](i = '') ⇒ Object
#
GamesAndRpgParadise::Mud::Characters[]
#
108 109 110 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 108 def self.[](i = '') new(i) end |
.load(file_or_hash) ⇒ Object
#
GamesAndRpgParadise::Mud::Character.load
This method expects a hash such as:
{:character_name=>"shevy", :gender=>"male", :age=>"33"}
Alternatively, it accepts a yaml .yml file.
#
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 76 def self.load(file_or_hash) if file_or_hash.is_a? Array # iterate through them file_or_hash.each {|entry| Mud::Character.load(entry) } else if file_or_hash.is_a? Hash _ = Character.new if file_or_hash.has_key? :character_name _.character_name = file_or_hash.delete(:character_name) end if file_or_hash.has_key? :gender _.gender = file_or_hash.delete(:gender) end if file_or_hash.has_key? :age _.age = file_or_hash.delete(:age) end return _ else if file_or_hash.include? '.yml' # We assume a yaml file here. # If we provide a .yml file then we will call ourself again. return Character.load(YAML.load_file(file_or_hash)) else raise 'Please provide a yaml .yml file.' end end end end |
Instance Method Details
#reset ⇒ Object
#
reset (reset tag)
#
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 46 def reset # ======================================================================= # # === @character_name # ======================================================================= # @character_name = '' # ======================================================================= # # === @gender # ======================================================================= # @gender = '' # ======================================================================= # # === @age # ======================================================================= # @age = '' end |
#run ⇒ Object
#
run (run tag)
#
64 65 |
# File 'lib/games_and_rpg_paradise/mud/character/character.rb', line 64 def run end |