Sha256: d278fd4ce557f276d7e17c53ebfbe5b8f836aa0561d296acdcad13b76698345c

Contents?: true

Size: 756 Bytes

Versions: 1

Compression:

Stored size: 756 Bytes

Contents

require 'xiv_lodestone/lodestone_helper'
require 'json'

module XIVLodestone
  class CollectableList
    attr_reader :list

    Collectable = Struct.new(:name, :icon_url)

    def initialize(collectable_path)
      @list = []
      parse_collectable(collectable_path)
    end
    # Uses gem Oj to dump MountList to JSON
    def to_json()
      @list.map { |obj| Hash[obj.each_pair.to_a] }.to_json
    end
    #### Private Methods ####
    def parse_collectable(collectable_path)
      collectable_path.each do |collectable|
        @list.push(Collectable.new(
          collectable['title'].split.map(&:capitalize)*' ',
          collectable.at_xpath('img')['src']))
      end
    end

    private :parse_collectable
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xiv_lodestone-0.0.7 lib/xiv_lodestone/lodestone_character_collectable.rb