Class: XIVLodestone::Character

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(args = {}) ⇒ Character

default constructor, handles styles of arguments

  1. Character.new(:name => “CHARACTER_NAME”, :server => “SERVER_NAME”)

  2. Character.new(:name => “CHARACTER_NAME”)

  3. 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_nameObject

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

#jobObject

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_nameObject

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

#minionsObject

Returns a #Array of characters minions



33
34
35
# File 'lib/xiv_lodestone/lodestone_character.rb', line 33

def minions
  @minions.list
end

#mountsObject

Returns a #Array of characters mounts



29
30
31
# File 'lib/xiv_lodestone/lodestone_character.rb', line 29

def mounts
  @mounts.list
end

#to_jsonObject

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