Class: XIVLodestone::Character
- Inherits:
-
Object
- Object
- XIVLodestone::Character
- Defined in:
- lib/xiv_lodestone/lodestone_character.rb
Overview
A Object that represents a FFXIV:ARR character, all information is obtained from the lodestone website.
Instance Method Summary collapse
-
#first_name ⇒ Object
Returns a #String with characters first name.
-
#initialize(args = Hash.new) ⇒ Character
constructor
default constructor, handles styles of arguments 1.
-
#last_name ⇒ Object
Returns a #String with characters last name.
-
#method_missing(method) ⇒ Object
Generates missing methods from @profile hash keys.
-
#minions ⇒ Object
Returns a #Array of characters minions.
-
#mounts ⇒ Object
Returns a #Array of characters mounts.
-
#to_json ⇒ Object
Uses gem Oj to dump Character Object to JSON.
Constructor Details
#initialize(args = Hash.new) ⇒ Character
default constructor, handles styles of arguments
-
Character.new(:name => “CHARACTER_NAME”, :server => “SERVER_NAME”)
-
Character.new(:name => “CHARACTER_NAME”)
-
Character.new(:id => ID_NUMBER)
15 16 17 18 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 15 def initialize(args = Hash.new) @profile = Hash.new() initialise_profile(Helper.process_args(args)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
Generates missing methods from @profile hash keys
36 37 38 39 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 36 def method_missing(method) return @profile[method] if @profile.key?(method) super end |
Instance Method Details
#first_name ⇒ Object
Returns a #String with characters first name
20 21 22 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 20 def first_name() @profile[:name].split(/ /).first end |
#last_name ⇒ Object
Returns a #String with characters last name
24 25 26 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 24 def last_name() @profile[:name].split(/ /).last end |
#minions ⇒ Object
Returns a #Array of characters minions
32 33 34 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 32 def minions() @minions.list end |
#mounts ⇒ Object
Returns a #Array of characters mounts
28 29 30 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 28 def mounts() @mounts.list end |
#to_json ⇒ Object
Uses gem Oj to dump Character Object to JSON
41 42 43 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 41 def to_json() Oj.dump(@profile) end |