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 = {}) ⇒ Character
constructor
default constructor, handles styles of arguments 1.
-
#job ⇒ Object
Returns the current character job.
-
#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 = {}) ⇒ 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)
16 17 18 19 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 16 def initialize(args = {}) @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
41 42 43 44 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 41 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
21 22 23 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 21 def first_name @profile[:name].split(/ /).first end |
#job ⇒ Object
Returns the current character job
37 38 39 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 37 def job @profile[:gear].soul_crystal.name.gsub("Soul of the ", "").delete!("\n\t") end |
#last_name ⇒ Object
Returns a #String with characters last name
25 26 27 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 25 def last_name @profile[:name].split(/ /).last end |
#minions ⇒ Object
Returns a #Array of characters minions
33 34 35 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 33 def minions @minions.list end |
#mounts ⇒ Object
Returns a #Array of characters mounts
29 30 31 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 29 def mounts @mounts.list end |
#to_json ⇒ Object
Uses gem Oj to dump Character Object to JSON
46 47 48 |
# File 'lib/xiv_lodestone/lodestone_character.rb', line 46 def to_json @profile.to_json end |