Class: SimpleXmlParser::FideXmlParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/simple_xml_parser/fide_xml_parser.rb

Overview

This class is provided as an example of how the Parser can be subclassed to implement specialized behavior for your data file.

It parses chess player/rating “combined” XML files provided at ratings.fide.com/download_lists.phtml.

Constant Summary collapse

INTEGER_FIELDS =

These field names will work even if field_name_renames are provided, because they are accessed before the renaming is done.

%w[
  birthday
  k
  blitz_k
  rapid_k
  rating
  blitz_rating
  rapid_rating
  games
  blitz_games
  rapid_games
].map(&:freeze)

Constants inherited from Parser

Parser::ANSI_GO_TO_LINE_START

Instance Attribute Summary

Attributes inherited from Parser

#array_name, #current_property_name, #field_name_renames, #input_record_count, #integer_fields, #key_filter, #output_record_count, #record, #record_filter, #record_name, #records, #start_time

Instance Method Summary collapse

Methods inherited from Parser

#characters, #current_time, #end_element, #finish, #include_this_field?, #maybe_convert_to_integer, #output_field_name, #output_status, #parse, #start_element

Constructor Details

#initialize(key_filter: nil, record_filter: nil, field_name_renames: nil) ⇒ FideXmlParser

Returns a new instance of FideXmlParser.



27
28
29
30
31
32
33
34
# File 'lib/simple_xml_parser/fide_xml_parser.rb', line 27

def initialize(key_filter: nil, record_filter: nil, field_name_renames: nil)
  super(array_name:         'playerslist',
        record_name:        'player',
        integer_fields:     INTEGER_FIELDS,
        key_filter:         key_filter,
        record_filter:      record_filter,
        field_name_renames: field_name_renames)
end