Class: XIVLodestone::AttributeList

Inherits:
Object
  • Object
show all
Defined in:
lib/xiv_lodestone/lodestone_character_attribute.rb

Overview

A Object that represents a set of atrributes from lodestone website. The class parsers a given xpath for attributes and stores them in a Hash. All method names are based of names of attributes from lodestone website

Constant Summary collapse

@@attribute_hash =
[ "strength", "dexterity", "vitality", "intelligence", "mind", "piety" ]

Instance Method Summary collapse

Constructor Details

#initialize(attribute_path) ⇒ AttributeList

Returns a new instance of AttributeList.



12
13
14
15
# File 'lib/xiv_lodestone/lodestone_character_attribute.rb', line 12

def initialize(attribute_path)
  @attributes = {}
  parse_attributes(attribute_path)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object

Generate methods from each key in the @attribute hash



17
18
19
20
# File 'lib/xiv_lodestone/lodestone_character_attribute.rb', line 17

def method_missing(method)
  return @attributes[method] if @attributes.key?(method)
  super
end

Instance Method Details

#to_jsonObject

Converts t



22
23
24
# File 'lib/xiv_lodestone/lodestone_character_attribute.rb', line 22

def to_json()
  @attributes.to_json
end