ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::LoadHandler

Inherits:
Object
  • Object
show all

Overview

Progress and result callback protocol for ModraUp::DefinitionList#load_from_url. The official documentation describes it as:

Interface: Not required to inherit from this class; any object that implements these methods can serve as a handler (e.g., Dynamic Components' DCDownloader is a regular Ruby class). This class is convenient for defined?(ModraUp::LoadHandler) and training purposes.

Examples:

class BoxHandler < ModraUp::LoadHandler
  def cancelled?
    false
  end
  def onPercentChange(percent)
    percent
  end
  def onSuccess
  end
  def onFailure(message)
    message
  end
end
defined?(ModraUp::LoadHandler)  #=> true

Instance Method Summary # collapse

Instance Method Details

handler.cancelled? ⇒ Boolean

Repeatedly prompts during the download. Returns true to cancel, then calls #onFailure.

Returns:

  • (Boolean)

Examples:

class BoxHandler < ModraUp::LoadHandler
  def cancelled?
    false
  end
end

handler.onPercentChange(percent) ⇒ nil

Download progress. percent ranges from approximately 0 to 100.

Parameters:

  • percent (Float)

Returns:

  • (nil)

Examples:

class BoxHandler < ModraUp::LoadHandler
  def onPercentChange(percent)
    percent
  end
end

handler.onSuccess ⇒ nil

The SKP definition table has been loaded.

Returns:

  • (nil)

Examples:

class BoxHandler < ModraUp::LoadHandler
  def onSuccess
  end
end

handler.onFailure(message) ⇒ nil

Cancel, network error, or not a valid SKP.

Parameters:

  • message (String)

Returns:

  • (nil)

Examples:

class BoxHandler < ModraUp::LoadHandler
  def onFailure(message)
    message
  end
end