Class: OsuRuby::Database::BaseDB Abstract

Inherits:
Object
  • Object
show all
Includes:
Interface::AbstractClass
Defined in:
(osu-ruby2 0.0.2) osu-ruby2/database/file.rb

Overview

This class is abstract.

This is base of database reading. Please understand this page were meant for developers of this library. But you can try understanding this part for other references.

Note:

First of all, this database must be used with care. I only provide references or personal data fixes. I do not condone cheating in osu!, please understand. Any misconducts that is done by using this library, I nor the devs, do not give consent for doing so.

Second, for any changes that happens within osu! database file itself they may not be noted in here due to some reasons. If any of you wanted to fill out the blankness from any version range, feel free to let me know.

Please do not use :send commands to invoke those privates, because they are part of private API. They are not meant to return value, being used outside :read_file or :write_to_file function.

Data structure itself are build by peppy and his dev team.

Direct Known Subclasses

CollectionDB, OsuDB, ReplayData, ReplayGraph, ScoreDB

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Interface::MultiplexerInterface

extended

Constructor Details

#initialize(file = nil) ⇒ BaseDB

Instantiate a simple skeleton

Instance Attribute Details

#versionObject (readonly)

Represents database version

Class Method Details

.load(file) ⇒ BaseDB

Loads the database from the file directly

Returns:

Instance Method Details

#determine_struct_bytes(io, item)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method is abstract.
Note:

There's no sanity check for this, as it's supposed to have a proper Hash-struct-like format. For the convention, each type always starts with :_type key that signifies struct type itself.

This method returns an undefined value.

Parameters:

  • io (IO::DotNetIO)

    a recurring DotNetIO to use

  • item (Hash)

    the struct to pass on

#initialize_copy(other) ⇒ Object

#inspectString

Returns:

  • (String)

#read_fileBoolean #read_file(filename) ⇒ Boolean #read_file(dotnet_io) ⇒ Boolean #read_file(io) ⇒ Boolean

Read from source

Overloads:

  • #read_fileBoolean

    Opens a previously assigned filename database. Closes IO after use.

  • #read_file(filename) ⇒ Boolean

    Opens an existing database. This will change the internal filename pointer. Closes IO after use.

    Parameters:

    • filename (String)

      a representation of a filename

  • #read_file(dotnet_io) ⇒ Boolean

    Pass the baton of the DotNetIO usage. Using this will not close the IO aftermath.

    Parameters:

  • #read_file(io) ⇒ Boolean

    Reads from existing IO object. Using this will not close the IO aftermath.

    Parameters:

    • io (::IO)

      any IO object (meant for StringIO but others sure)

Returns:

  • (Boolean)

    EOF-check

#read_structs(io, &block) ⇒ Array #read_structs(io, container, &block)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This allows to read an array of object to be read consecutively. First Int32 signifies the length of the array, after that perform the given block (must, no sanity check).

Overloads:

  • #read_structs(io, &block) ⇒ Array

    Returns with consistent struct data.

    Parameters:

    • io (IO::DotNetIO)

      a recurring DotNetIO to use

    • block (Proc)

      a block to process how the struct is processed onwards.

    Returns:

    • (Array)

      with consistent struct data.

  • #read_structs(io, container, &block)

    This method returns an undefined value.

    Parameters:

    • io (IO::DotNetIO)

      a recurring DotNetIO to use

    • container (Array)

      container to store directly all the values returned by the block

    • block (Proc)

      a block to process how the struct is processed onwards.

#version!

This method returns an undefined value.

Enforces the database version to the library-supported one.

#write_structs(io, list) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Do not overload this method. Instead, implement the #determine_struct_bytes, things are handled there.

This function only removes some parts that can be considered as repetitive.

Parameters:

  • io (IO::DotNetIO)

    a recurring DotNetIO to use

  • list (Hash)

    the struct to pass on

Raises:

  • (TypeError)

    sanity-check when there are more than one-struct type inside the struct container. Consider you are doing it wrong.

See Also:

#write_to_file #write_to_file(filename) #write_to_file(dotnet_io) #write_to_file(io)

This method returns an undefined value.

Write database to destination

Overloads:

  • #write_to_file

    Writes to previously assigned filename database. Closes IO after use.

  • #write_to_file(filename)

    Writes into a new database. This will not change the internal filename pointer. Closes IO after use.

    Parameters:

    • filename (String)

      a representation of a filename

  • #write_to_file(dotnet_io)

    Pass the baton of the DotNetIO usage. Using this will not close the IO aftermath.

    Parameters:

  • #write_to_file(io)

    Writes existing IO object. Using this will not close the IO aftermath.

    Parameters:

    • io (::IO)

      any IO object (meant for StringIO but others sure)