Class: PfrpgReaders::PFRPGCharacter

Inherits:
Object
  • Object
show all
Defined in:
lib/pfrpg_readers/pfrpg_character.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(character) ⇒ PFRPGCharacter

Returns a new instance of PFRPGCharacter.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 6

def initialize(character)
  @character    = character
  @attributes   = AttributesReader.new(character)
  @demographics = DemographicsReader.new(character)
  @combat       = CombatReader.new(character)
  @saves        = SavesReader.new(character)
  @misc         = MiscReader.new(character)
  @skills       = SkillsReader.new(character)
  @inventory    = InventoryReader.new(character)
  @spells       = SpellsReader.new(character)
  @avatar       = character.avatar if character.respond_to? 'avatar'
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def attributes
  @attributes
end

#avatarObject (readonly)

Returns the value of attribute avatar.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def avatar
  @avatar
end

#characterObject (readonly)

Returns the value of attribute character.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def character
  @character
end

#combatObject (readonly)

Returns the value of attribute combat.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def combat
  @combat
end

#featsObject (readonly)

Returns the value of attribute feats.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def feats
  @feats
end

#inventoryObject (readonly)

Returns the value of attribute inventory.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def inventory
  @inventory
end

#miscObject (readonly)

Returns the value of attribute misc.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def misc
  @misc
end

#skillsObject (readonly)

Returns the value of attribute skills.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def skills
  @skills
end

#spellsObject (readonly)

Returns the value of attribute spells.



3
4
5
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 3

def spells
  @spells
end

Instance Method Details

#as_json(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 19

def as_json(options={})
 p = {
    :id         => @character.id,
    :uuid         => @character.uuid,
    :character  => @character,
    :demographics => @demographics,
    :attributes => @attributes,
    :combat     => @combat,
    :saves      => @saves,
    :misc       => @misc,
    :skills     => @skills,
    :spells     => @spells,
    :inventory  => @inventory
  }
  p[:avatar] = AvatarURL.new(@avatar) if @avatar
  p
end

#find_by_id(id) ⇒ Object



37
38
39
# File 'lib/pfrpg_readers/pfrpg_character.rb', line 37

def find_by_id(id)
  Character.find(id)
end