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 = Hash.new) ⇒ 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)



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_nameObject

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_nameObject

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

#minionsObject

Returns a #Array of characters minions



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

def minions()
  @minions.list
end

#mountsObject

Returns a #Array of characters mounts



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

def mounts()
  @mounts.list
end

#to_jsonObject

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