Skip to content

Instantly share code, notes, and snippets.

@kaiwren
Created March 13, 2015 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaiwren/f41ac080eb4f6e2b576a to your computer and use it in GitHub Desktop.
Save kaiwren/f41ac080eb4f6e2b576a to your computer and use it in GitHub Desktop.
Compiled GoL via Opal
(function(undefined) {
if (typeof(this.Opal) !== 'undefined') {
console.warn('Opal already loaded. Loading twice can cause troubles, please fix your setup.');
return this.Opal;
}
// The Opal object that is exposed globally
var Opal = this.Opal = {};
// All bridged classes - keep track to donate methods from Object
var bridged_classes = Opal.bridged_classes = [];
// TopScope is used for inheriting constants from the top scope
var TopScope = function(){};
// Opal just acts as the top scope
TopScope.prototype = Opal;
// To inherit scopes
Opal.constructor = TopScope;
// List top scope constants
Opal.constants = [];
// This is a useful reference to global object inside ruby files
Opal.global = this;
// Minify common function calls
var $hasOwn = Opal.hasOwnProperty;
var $slice = Opal.slice = Array.prototype.slice;
// Generates unique id for every ruby object
var unique_id = 0;
// Return next unique id
Opal.uid = function() {
return unique_id++;
};
// Table holds all class variables
Opal.cvars = {};
// Globals table
Opal.gvars = {};
// Exit function, this should be replaced by platform specific implementation
// (See nodejs and phantom for examples)
Opal.exit = function(status) { if (Opal.gvars.DEBUG) console.log('Exited with status '+status); };
/**
Get a constant on the given scope. Every class and module in Opal has a
scope used to store, and inherit, constants. For example, the top level
`Object` in ruby has a scope accessible as `Opal.Object.$$scope`.
To get the `Array` class using this scope, you could use:
Opal.Object.$$scope.get("Array")
If a constant with the given name cannot be found, then a dispatch to the
class/module's `#const_method` is called, which by default will raise an
error.
@param [String] name the name of the constant to lookup
@returns [RubyObject]
*/
Opal.get = function(name) {
var constant = this[name];
if (constant == null) {
return this.base.$const_missing(name);
}
return constant;
};
/*
* Create a new constants scope for the given class with the given
* base. Constants are looked up through their parents, so the base
* scope will be the outer scope of the new klass.
*/
function create_scope(base, klass, id) {
var const_alloc = function() {};
var const_scope = const_alloc.prototype = new base.constructor();
klass.$$scope = const_scope;
klass.$$base_module = base.base;
const_scope.base = klass;
const_scope.constructor = const_alloc;
const_scope.constants = [];
if (id) {
klass.$$orig_scope = base;
base[id] = base.constructor[id] = klass;
base.constants.push(id);
}
}
Opal.create_scope = create_scope;
/*
* A `class Foo; end` expression in ruby is compiled to call this runtime
* method which either returns an existing class of the given name, or creates
* a new class in the given `base` scope.
*
* If a constant with the given name exists, then we check to make sure that
* it is a class and also that the superclasses match. If either of these
* fail, then we raise a `TypeError`. Note, superklass may be null if one was
* not specified in the ruby code.
*
* We pass a constructor to this method of the form `function ClassName() {}`
* simply so that classes show up with nicely formatted names inside debuggers
* in the web browser (or node/sprockets).
*
* The `base` is the current `self` value where the class is being created
* from. We use this to get the scope for where the class should be created.
* If `base` is an object (not a class/module), we simple get its class and
* use that as the base instead.
*
* @param [Object] base where the class is being created
* @param [Class] superklass superclass of the new class (may be null)
* @param [String] id the name of the class to be created
* @param [Function] constructor function to use as constructor
* @return [Class] new or existing ruby class
*/
Opal.klass = function(base, superklass, id, constructor) {
// If base is an object, use its class
if (!base.$$is_class) {
base = base.$$class;
}
// Not specifying a superclass means we can assume it to be Object
if (superklass === null) {
superklass = ObjectClass;
}
var klass = base.$$scope[id];
// If a constant exists in the scope, then we must use that
if ($hasOwn.call(base.$$scope, id) && klass.$$orig_scope === base.$$scope) {
// Make sure the existing constant is a class, or raise error
if (!klass.$$is_class) {
throw Opal.TypeError.$new(id + " is not a class");
}
// Make sure existing class has same superclass
if (superklass !== klass.$$super && superklass !== ObjectClass) {
throw Opal.TypeError.$new("superclass mismatch for class " + id);
}
}
else if (typeof(superklass) === 'function') {
// passed native constructor as superklass, so bridge it as ruby class
return bridge_class(id, superklass);
}
else {
// if class doesnt exist, create a new one with given superclass
klass = boot_class(superklass, constructor);
// name class using base (e.g. Foo or Foo::Baz)
klass.$$name = id;
// every class gets its own constant scope, inherited from current scope
create_scope(base.$$scope, klass, id);
// Name new class directly onto current scope (Opal.Foo.Baz = klass)
base[id] = base.$$scope[id] = klass;
// Copy all parent constants to child, unless parent is Object
if (superklass !== ObjectClass && superklass !== BasicObjectClass) {
donate_constants(superklass, klass);
}
// call .inherited() hook with new class on the superclass
if (superklass.$inherited) {
superklass.$inherited(klass);
}
}
return klass;
};
// Create generic class with given superclass.
function boot_class(superklass, constructor) {
var alloc = boot_class_alloc(null, constructor, superklass)
return boot_class_object(superklass, alloc);
}
// Make `boot_class` available to the JS-API
Opal.boot = boot_class;
/*
* The class object itself (as in `Class.new`)
*
* @param [(Opal) Class] superklass Another class object (as in `Class.new`)
* @param [constructor] alloc The constructor that holds the prototype
* that will be used for instances of the
* newly constructed class.
*/
function boot_class_object(superklass, alloc) {
var singleton_class = function() {};
singleton_class.prototype = superklass.constructor.prototype;
function OpalClass() {}
OpalClass.prototype = new singleton_class();
var klass = new OpalClass();
setup_module_or_class_object(klass, OpalClass, superklass, alloc.prototype);
// @property $$alloc This is the constructor of instances of the current
// class. Its prototype will be used for method lookup
klass.$$alloc = alloc;
// @property $$proto.$$class Make available to instances a reference to the
// class they belong to.
klass.$$proto.$$class = klass;
return klass;
}
/*
* Adds common/required properties to a module or class object
* (as in `Module.new` / `Class.new`)
*
* @param module The module or class that needs to be prepared
*
* @param constructor The constructor of the module or class itself,
* usually it's already assigned by using `new`. Some
* ipothesis on why it's needed can be found below.
*
* @param superklass The superclass of the class/module object, for modules
* is `Module` (of `ModuleClass` in JS context)
*
* @param prototype The prototype on which the class/module methods will
* be stored.
*/
function setup_module_or_class_object(module, constructor, superklass, prototype) {
// @property $$id Each class is assigned a unique `id` that helps
// comparation and implementation of `#object_id`
module.$$id = unique_id++;
// @property $$proto This is the prototype on which methods will be defined
module.$$proto = prototype;
// @property constructor keeps a ref to the constructor, but apparently the
// constructor is already set on:
//
// `var module = new constructor` is called.
//
// Maybe there are some browsers not abiding (IE6?)
module.constructor = constructor;
// @property $$is_class Clearly mark this as a class-like
module.$$is_class = true;
// @property $$super the superclass, doesn't get changed by module inclusions
module.$$super = superklass;
// @property $$parent direct parent class or module
// starts with the superclass, after module inclusion is
// the last included module
module.$$parent = superklass;
// @property $$methods keeps track of methods defined on the class
// but seems to be used just by `define_basic_object_method`
// and for donating (Ruby) Object methods to bridged classes
// TODO: check if it can be removed
module.$$methods = [];
// @property $$inc included modules
module.$$inc = [];
}
/**
Define new module (or return existing module). The given `base` is basically
the current `self` value the `module` statement was defined in. If this is
a ruby module or class, then it is used, otherwise if the base is a ruby
object then that objects real ruby class is used (e.g. if the base is the
main object, then the top level `Object` class is used as the base).
If a module of the given name is already defined in the base, then that
instance is just returned.
If there is a class of the given name in the base, then an error is
generated instead (cannot have a class and module of same name in same base).
Otherwise, a new module is created in the base with the given name, and that
new instance is returned back (to be referenced at runtime).
@param [RubyModule or Class] base class or module this definition is inside
@param [String] id the name of the new (or existing) module
@returns [RubyModule]
*/
Opal.module = function(base, id) {
var module;
if (!base.$$is_class) {
base = base.$$class;
}
if ($hasOwn.call(base.$$scope, id)) {
module = base.$$scope[id];
if (!module.$$is_mod && module !== ObjectClass) {
throw Opal.TypeError.$new(id + " is not a module");
}
}
else {
module = boot_module_object();
module.$$name = id;
create_scope(base.$$scope, module, id);
// Name new module directly onto current scope (Opal.Foo.Baz = module)
base[id] = base.$$scope[id] = module;
}
return module;
};
/*
* Internal function to create a new module instance. This simply sets up
* the prototype hierarchy and method tables.
*/
function boot_module_object() {
var mtor = function() {};
mtor.prototype = ModuleClass.constructor.prototype;
function module_constructor() {}
module_constructor.prototype = new mtor();
var module = new module_constructor();
var module_prototype = {};
setup_module_or_class_object(module, module_constructor, ModuleClass, module_prototype);
module.$$is_mod = true;
module.$$dep = [];
return module;
}
/**
Return the singleton class for the passed object.
If the given object alredy has a singleton class, then it will be stored on
the object as the `$$meta` property. If this exists, then it is simply
returned back.
Otherwise, a new singleton object for the class or object is created, set on
the object at `$$meta` for future use, and then returned.
@param [RubyObject] object the ruby object
@returns [RubyClass] the singleton class for object
*/
Opal.get_singleton_class = function(object) {
if (object.$$meta) {
return object.$$meta;
}
if (object.$$is_class) {
return build_class_singleton_class(object);
}
return build_object_singleton_class(object);
};
/**
Build the singleton class for an existing class.
NOTE: Actually in MRI a class' singleton class inherits from its
superclass' singleton class which in turn inherits from Class.
@param [RubyClass] klass
@returns [RubyClass]
*/
function build_class_singleton_class(klass) {
var meta = new Opal.Class.$$alloc;
meta.$$class = Opal.Class;
meta.$$proto = klass.constructor.prototype;
meta.$$is_singleton = true;
meta.$$inc = [];
meta.$$methods = [];
meta.$$scope = klass.$$scope;
return klass.$$meta = meta;
}
/**
Build the singleton class for a Ruby (non class) Object.
@param [RubyObject] object
@returns [RubyClass]
*/
function build_object_singleton_class(object) {
var orig_class = object.$$class,
class_id = "#<Class:#<" + orig_class.$$name + ":" + orig_class.$$id + ">>";
var Singleton = function () {};
var meta = Opal.boot(orig_class, Singleton);
meta.$$name = class_id;
meta.$$proto = object;
meta.$$class = orig_class.$$class;
meta.$$scope = orig_class.$$scope;
meta.$$parent = orig_class;
return object.$$meta = meta;
}
/**
The actual inclusion of a module into a class.
## Class `$$parent` and `iclass`
To handle `super` calls, every class has a `$$parent`. This parent is
used to resolve the next class for a super call. A normal class would
have this point to its superclass. However, if a class includes a module
then this would need to take into account the module. The module would
also have to then point its `$$parent` to the actual superclass. We
cannot modify modules like this, because it might be included in more
then one class. To fix this, we actually insert an `iclass` as the class'
`$$parent` which can then point to the superclass. The `iclass` acts as
a proxy to the actual module, so the `super` chain can then search it for
the required method.
@param [RubyModule] module the module to include
@param [RubyClass] klass the target class to include module into
@returns [null]
*/
Opal.append_features = function(module, klass) {
var included = klass.$$inc;
// check if this module is already included in the klass
for (var j = 0, jj = included.length; j < jj; j++) {
if (included[j] === module) {
return;
}
}
included.push(module);
module.$$dep.push(klass);
// iclass
var iclass = {
$$name: module.$$name,
$$proto: module.$$proto,
$$parent: klass.$$parent,
$$module: module,
$$iclass: true
};
klass.$$parent = iclass;
var donator = module.$$proto,
prototype = klass.$$proto,
methods = module.$$methods;
for (var i = 0, length = methods.length; i < length; i++) {
var method = methods[i], current;
if ( prototype.hasOwnProperty(method) &&
!(current = prototype[method]).$$donated && !current.$$stub ) {
// if the target class already has a method of the same name defined
// and that method was NOT donated, then it must be a method defined
// by the class so we do not want to override it
}
else {
prototype[method] = donator[method];
prototype[method].$$donated = true;
}
}
if (klass.$$dep) {
donate_methods(klass, methods.slice(), true);
}
donate_constants(module, klass);
};
// Boot a base class (makes instances).
function boot_class_alloc(id, constructor, superklass) {
if (superklass) {
var ctor = function() {};
ctor.prototype = superklass.$$proto || superklass.prototype;
if (id) {
ctor.displayName = id;
}
constructor.prototype = new ctor();
}
constructor.prototype.constructor = constructor;
return constructor;
}
/*
* Builds the class object for core classes:
* - make the class object have a singleton class
* - make the singleton class inherit from its parent singleton class
*
* @param id [String] the name of the class
* @param alloc [Function] the constructor for the core class instances
* @param superclass [Class alloc] the constructor of the superclass
*/
function boot_core_class_object(id, alloc, superclass) {
var superclass_constructor = function() {};
superclass_constructor.prototype = superclass.prototype;
var singleton_class = function() {};
singleton_class.prototype = new superclass_constructor();
singleton_class.displayName = "#<Class:"+id+">";
// the singleton_class acts as the class object constructor
var klass = new singleton_class();
setup_module_or_class_object(klass, singleton_class, superclass, alloc.prototype);
klass.$$alloc = alloc;
klass.$$name = id;
// Give all instances a ref to their class
alloc.prototype.$$class = klass;
Opal[id] = klass;
Opal.constants.push(id);
return klass;
}
/*
* For performance, some core ruby classes are toll-free bridged to their
* native javascript counterparts (e.g. a ruby Array is a javascript Array).
*
* This method is used to setup a native constructor (e.g. Array), to have
* its prototype act like a normal ruby class. Firstly, a new ruby class is
* created using the native constructor so that its prototype is set as the
* target for th new class. Note: all bridged classes are set to inherit
* from Object.
*
* Bridged classes are tracked in `bridged_classes` array so that methods
* defined on Object can be "donated" to all bridged classes. This allows
* us to fake the inheritance of a native prototype from our Object
* prototype.
*
* Example:
*
* bridge_class("Proc", Function);
*
* @param [String] name the name of the ruby class to create
* @param [Function] constructor native javascript constructor to use
* @return [Class] returns new ruby class
*/
function bridge_class(name, constructor) {
var klass = boot_class_object(ObjectClass, constructor);
klass.$$name = name;
create_scope(Opal, klass, name);
bridged_classes.push(klass);
var object_methods = BasicObjectClass.$$methods.concat(ObjectClass.$$methods);
for (var i = 0, len = object_methods.length; i < len; i++) {
var meth = object_methods[i];
constructor.prototype[meth] = ObjectClass.$$proto[meth];
}
add_stubs_subscriber(constructor.prototype);
return klass;
}
/*
* constant assign
*/
Opal.casgn = function(base_module, name, value) {
var scope = base_module.$$scope;
if (value.$$is_class && value.$$name === nil) {
value.$$name = name;
}
if (value.$$is_class) {
value.$$base_module = base_module;
}
scope.constants.push(name);
return scope[name] = value;
};
/*
* constant decl
*/
Opal.cdecl = function(base_scope, name, value) {
base_scope.constants.push(name);
return base_scope[name] = value;
};
/*
* When a source module is included into the target module, we must also copy
* its constants to the target.
*/
function donate_constants(source_mod, target_mod) {
var source_constants = source_mod.$$scope.constants,
target_scope = target_mod.$$scope,
target_constants = target_scope.constants;
for (var i = 0, length = source_constants.length; i < length; i++) {
target_constants.push(source_constants[i]);
target_scope[source_constants[i]] = source_mod.$$scope[source_constants[i]];
}
};
/*
* Methods stubs are used to facilitate method_missing in opal. A stub is a
* placeholder function which just calls `method_missing` on the receiver.
* If no method with the given name is actually defined on an object, then it
* is obvious to say that the stub will be called instead, and then in turn
* method_missing will be called.
*
* When a file in ruby gets compiled to javascript, it includes a call to
* this function which adds stubs for every method name in the compiled file.
* It should then be safe to assume that method_missing will work for any
* method call detected.
*
* Method stubs are added to the BasicObject prototype, which every other
* ruby object inherits, so all objects should handle method missing. A stub
* is only added if the given property name (method name) is not already
* defined.
*
* Note: all ruby methods have a `$` prefix in javascript, so all stubs will
* have this prefix as well (to make this method more performant).
*
* Opal.add_stubs(["$foo", "$bar", "$baz="]);
*
* All stub functions will have a private `$$stub` property set to true so
* that other internal methods can detect if a method is just a stub or not.
* `Kernel#respond_to?` uses this property to detect a methods presence.
*
* @param [Array] stubs an array of method stubs to add
*/
Opal.add_stubs = function(stubs) {
var subscribers = Opal.stub_subscribers;
var subscriber;
for (var i = 0, length = stubs.length; i < length; i++) {
var method_name = stubs[i], stub = stub_for(method_name);
for (var j = 0; j < subscribers.length; j++) {
subscriber = subscribers[j];
if (!(method_name in subscriber)) {
subscriber[method_name] = stub;
}
}
}
};
/*
* Add a prototype to the subscribers list, and (TODO) add previously stubbed
* methods.
*
* @param [Prototype]
*/
function add_stubs_subscriber(prototype) {
// TODO: Add previously stubbed methods too.
Opal.stub_subscribers.push(prototype);
}
/*
* Keep a list of prototypes that want method_missing stubs to be added.
*
* @default [Prototype List] BasicObject.prototype
*/
Opal.stub_subscribers = [BasicObject.prototype];
/*
* Add a method_missing stub function to the given prototype for the
* given name.
*
* @param [Prototype] prototype the target prototype
* @param [String] stub stub name to add (e.g. "$foo")
*/
function add_stub_for(prototype, stub) {
var method_missing_stub = stub_for(stub);
prototype[stub] = method_missing_stub;
}
/*
* Generate the method_missing stub for a given method name.
*
* @param [String] method_name The js-name of the method to stub (e.g. "$foo")
*/
function stub_for(method_name) {
function method_missing_stub() {
// Copy any given block onto the method_missing dispatcher
this.$method_missing.$$p = method_missing_stub.$$p;
// Set block property to null ready for the next call (stop false-positives)
method_missing_stub.$$p = null;
// call method missing with correct args (remove '$' prefix on method name)
return this.$method_missing.apply(this, [method_name.slice(1)].concat($slice.call(arguments)));
}
method_missing_stub.$$stub = true;
return method_missing_stub;
}
// Expose for other parts of Opal to use
Opal.add_stub_for = add_stub_for;
// Arity count error dispatcher
Opal.ac = function(actual, expected, object, meth) {
var inspect = (object.$$is_class ? object.$$name + '.' : object.$$class.$$name + '#') + meth;
var msg = '[' + inspect + '] wrong number of arguments(' + actual + ' for ' + expected + ')';
throw Opal.ArgumentError.$new(msg);
};
// Super dispatcher
Opal.find_super_dispatcher = function(obj, jsid, current_func, iter, defs) {
var dispatcher;
if (defs) {
dispatcher = obj.$$is_class ? defs.$$super : obj.$$class.$$proto;
}
else {
if (obj.$$is_class) {
dispatcher = obj.$$super;
}
else {
dispatcher = find_obj_super_dispatcher(obj, jsid, current_func);
}
}
dispatcher = dispatcher['$' + jsid];
dispatcher.$$p = iter;
return dispatcher;
};
// Iter dispatcher for super in a block
Opal.find_iter_super_dispatcher = function(obj, jsid, current_func, iter, defs) {
if (current_func.$$def) {
return Opal.find_super_dispatcher(obj, current_func.$$jsid, current_func, iter, defs);
}
else {
return Opal.find_super_dispatcher(obj, jsid, current_func, iter, defs);
}
};
function find_obj_super_dispatcher(obj, jsid, current_func) {
var klass = obj.$$meta || obj.$$class;
jsid = '$' + jsid;
while (klass) {
if (klass.$$proto[jsid] === current_func) {
// ok
break;
}
klass = klass.$$parent;
}
// if we arent in a class, we couldnt find current?
if (!klass) {
throw new Error("could not find current class for super()");
}
klass = klass.$$parent;
// else, let's find the next one
while (klass) {
var working = klass.$$proto[jsid];
if (working && working !== current_func) {
// ok
break;
}
klass = klass.$$parent;
}
return klass.$$proto;
};
/*
* Used to return as an expression. Sometimes, we can't simply return from
* a javascript function as if we were a method, as the return is used as
* an expression, or even inside a block which must "return" to the outer
* method. This helper simply throws an error which is then caught by the
* method. This approach is expensive, so it is only used when absolutely
* needed.
*/
Opal.ret = function(val) {
Opal.returner.$v = val;
throw Opal.returner;
};
// handles yield calls for 1 yielded arg
Opal.yield1 = function(block, arg) {
if (typeof(block) !== "function") {
throw Opal.LocalJumpError.$new("no block given");
}
if (block.length > 1 && arg.$$is_array) {
return block.apply(null, arg);
}
else {
return block(arg);
}
};
// handles yield for > 1 yielded arg
Opal.yieldX = function(block, args) {
if (typeof(block) !== "function") {
throw Opal.LocalJumpError.$new("no block given");
}
if (block.length > 1 && args.length == 1) {
if (args[0].$$is_array) {
return block.apply(null, args[0]);
}
}
if (!args.$$is_array) {
args = $slice.call(args);
}
return block.apply(null, args);
};
// Finds the corresponding exception match in candidates. Each candidate can
// be a value, or an array of values. Returns null if not found.
Opal.rescue = function(exception, candidates) {
for (var i = 0; i < candidates.length; i++) {
var candidate = candidates[i];
if (candidate.$$is_array) {
var result = Opal.rescue(exception, candidate);
if (result) {
return result;
}
}
else if (candidate['$==='](exception)) {
return candidate;
}
}
return null;
};
Opal.is_a = function(object, klass) {
if (object.$$meta === klass) {
return true;
}
var search = object.$$class;
while (search) {
if (search === klass) {
return true;
}
for (var i = 0, length = search.$$inc.length; i < length; i++) {
if (search.$$inc[i] == klass) {
return true;
}
}
search = search.$$super;
}
return false;
};
// Helper to convert the given object to an array
Opal.to_ary = function(value) {
if (value.$$is_array) {
return value;
}
else if (value.$to_ary && !value.$to_ary.$$stub) {
return value.$to_ary();
}
return [value];
};
/**
Used to get a list of rest keyword arguments. Method takes the given
keyword args, i.e. the hash literal passed to the method containing all
keyword arguemnts passed to method, as well as the used args which are
the names of required and optional arguments defined. This method then
just returns all key/value pairs which have not been used, in a new
hash literal.
@param given_args [Hash] all kwargs given to method
@param used_args [Object<String: true>] all keys used as named kwargs
@return [Hash]
*/
Opal.kwrestargs = function(given_args, used_args) {
var keys = [],
map = {},
key = null,
given_map = given_args.smap;
for (key in given_map) {
if (!used_args[key]) {
keys.push(key);
map[key] = given_map[key];
}
}
return Opal.hash2(keys, map);
};
/*
* Call a ruby method on a ruby object with some arguments:
*
* var my_array = [1, 2, 3, 4]
* Opal.send(my_array, 'length') # => 4
* Opal.send(my_array, 'reverse!') # => [4, 3, 2, 1]
*
* A missing method will be forwarded to the object via
* method_missing.
*
* The result of either call with be returned.
*
* @param [Object] recv the ruby object
* @param [String] mid ruby method to call
*/
Opal.send = function(recv, mid) {
var args = $slice.call(arguments, 2),
func = recv['$' + mid];
if (func) {
return func.apply(recv, args);
}
return recv.$method_missing.apply(recv, [mid].concat(args));
};
Opal.block_send = function(recv, mid, block) {
var args = $slice.call(arguments, 3),
func = recv['$' + mid];
if (func) {
func.$$p = block;
return func.apply(recv, args);
}
return recv.$method_missing.apply(recv, [mid].concat(args));
};
/*
* Donate methods for a class/module
*/
function donate_methods(klass, defined, indirect) {
var methods = klass.$$methods, included_in = klass.$$dep;
// if (!indirect) {
klass.$$methods = methods.concat(defined);
// }
if (included_in) {
for (var i = 0, length = included_in.length; i < length; i++) {
var includee = included_in[i];
var dest = includee.$$proto;
for (var j = 0, jj = defined.length; j < jj; j++) {
var method = defined[j];
dest[method] = klass.$$proto[method];
dest[method].$$donated = true;
}
if (includee.$$dep) {
donate_methods(includee, defined, true);
}
}
}
};
/**
Define the given method on the module.
This also handles donating methods to all classes that include this
module. Method conflicts are also handled here, where a class might already
have defined a method of the same name, or another included module defined
the same method.
@param [RubyModule] module the module method defined on
@param [String] jsid javascript friendly method name (e.g. "$foo")
@param [Function] body method body of actual function
*/
function define_module_method(module, jsid, body) {
module.$$proto[jsid] = body;
body.$$owner = module;
module.$$methods.push(jsid);
if (module.$$module_function) {
module[jsid] = body;
}
var included_in = module.$$dep;
if (included_in) {
for (var i = 0, length = included_in.length; i < length; i++) {
var includee = included_in[i];
var dest = includee.$$proto;
var current = dest[jsid];
if (dest.hasOwnProperty(jsid) && !current.$$donated && !current.$$stub) {
// target class has already defined the same method name - do nothing
}
else if (dest.hasOwnProperty(jsid) && !current.$$stub) {
// target class includes another module that has defined this method
var klass_includees = includee.$$inc;
for (var j = 0, jj = klass_includees.length; j < jj; j++) {
if (klass_includees[j] === current.$$owner) {
var current_owner_index = j;
}
if (klass_includees[j] === module) {
var module_index = j;
}
}
// only redefine method on class if the module was included AFTER
// the module which defined the current method body. Also make sure
// a module can overwrite a method it defined before
if (current_owner_index <= module_index) {
dest[jsid] = body;
dest[jsid].$$donated = true;
}
}
else {
// neither a class, or module included by class, has defined method
dest[jsid] = body;
dest[jsid].$$donated = true;
}
if (includee.$$dep) {
donate_methods(includee, [jsid], true);
}
}
}
}
/**
Used to define methods on an object. This is a helper method, used by the
compiled source to define methods on special case objects when the compiler
can not determine the destination object, or the object is a Module
instance. This can get called by `Module#define_method` as well.
## Modules
Any method defined on a module will come through this runtime helper.
The method is added to the module body, and the owner of the method is
set to be the module itself. This is used later when choosing which
method should show on a class if more than 1 included modules define
the same method. Finally, if the module is in `module_function` mode,
then the method is also defined onto the module itself.
## Classes
This helper will only be called for classes when a method is being
defined indirectly; either through `Module#define_method`, or by a
literal `def` method inside an `instance_eval` or `class_eval` body. In
either case, the method is simply added to the class' prototype. A special
exception exists for `BasicObject` and `Object`. These two classes are
special because they are used in toll-free bridged classes. In each of
these two cases, extra work is required to define the methods on toll-free
bridged class' prototypes as well.
## Objects
If a simple ruby object is the object, then the method is simply just
defined on the object as a singleton method. This would be the case when
a method is defined inside an `instance_eval` block.
@param [RubyObject or Class] obj the actual obj to define method for
@param [String] jsid the javascript friendly method name (e.g. '$foo')
@param [Function] body the literal javascript function used as method
@returns [null]
*/
Opal.defn = function(obj, jsid, body) {
if (obj.$$is_mod) {
define_module_method(obj, jsid, body);
}
else if (obj.$$is_class) {
obj.$$proto[jsid] = body;
if (obj === BasicObjectClass) {
define_basic_object_method(jsid, body);
}
else if (obj === ObjectClass) {
donate_methods(obj, [jsid]);
}
}
else {
obj[jsid] = body;
}
return nil;
};
/*
* Define a singleton method on the given object.
*/
Opal.defs = function(obj, jsid, body) {
if (obj.$$is_class || obj.$$is_mod) {
obj.constructor.prototype[jsid] = body;
}
else {
obj[jsid] = body;
}
};
function define_basic_object_method(jsid, body) {
BasicObjectClass.$$methods.push(jsid);
for (var i = 0, len = bridged_classes.length; i < len; i++) {
bridged_classes[i].$$proto[jsid] = body;
}
}
Opal.hash = function() {
if (arguments.length == 1 && arguments[0].$$class == Opal.Hash) {
return arguments[0];
}
var hash = new Opal.Hash.$$alloc(),
keys = [],
_map = {},
smap = {},
key, obj, length, khash;
hash.map = _map;
hash.smap = smap;
hash.keys = keys;
if (arguments.length == 1) {
if (arguments[0].$$is_array) {
var args = arguments[0];
for (var i = 0, ii = args.length; i < ii; i++) {
var pair = args[i];
if (pair.length !== 2) {
throw Opal.ArgumentError.$new("value not of length 2: " + pair.$inspect());
}
key = pair[0];
obj = pair[1];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
if (map[khash] == null) {
keys.push(key);
}
map[khash] = obj;
}
}
else {
obj = arguments[0];
for (key in obj) {
khash = key.$hash();
map[khash] = obj[khash];
keys.push(key);
}
}
}
else {
length = arguments.length;
if (length % 2 !== 0) {
throw Opal.ArgumentError.$new("odd number of arguments for Hash");
}
for (var j = 0; j < length; j++) {
key = arguments[j];
obj = arguments[++j];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
if (map[khash] == null) {
keys.push(key);
}
map[khash] = obj;
}
}
return hash;
};
/*
* hash2 is a faster creator for hashes that just use symbols and
* strings as keys. The map and keys array can be constructed at
* compile time, so they are just added here by the constructor
* function
*/
Opal.hash2 = function(keys, map) {
var hash = new Opal.Hash.$$alloc();
hash.keys = keys;
hash.map = {};
hash.smap = map;
return hash;
};
/*
* Create a new range instance with first and last values, and whether the
* range excludes the last value.
*/
Opal.range = function(first, last, exc) {
var range = new Opal.Range.$$alloc();
range.begin = first;
range.end = last;
range.exclude = exc;
return range;
};
// Require system
// --------------
(function(Opal) {
var loaded_features = ['corelib/runtime.js'],
require_table = {'corelib/runtime.js': true},
modules = {};
var current_dir = '.';
function mark_as_loaded(filename) {
if (require_table[filename]) {
return false;
}
loaded_features.push(filename);
require_table[filename] = true;
return true;
}
function normalize_loadable_path(path) {
var parts, part, new_parts = [], SEPARATOR = '/';
if (current_dir !== '.') {
path = current_dir.replace(/\/*$/, '/') + path;
}
parts = path.split(SEPARATOR);
for (var i = 0, ii = parts.length; i < ii; i++) {
part = parts[i];
if (part == '') continue;
(part === '..') ? new_parts.pop() : new_parts.push(part)
}
return new_parts.join(SEPARATOR);
}
function load(path) {
mark_as_loaded(path);
var module = modules[path];
if (module) {
module(Opal);
}
else {
var severity = Opal.dynamic_require_severity || 'warning';
var message = 'cannot load such file -- ' + path;
if (severity === "error") {
Opal.LoadError ? Opal.LoadError.$new(message) : function(){throw message}();
}
else if (severity === "warning") {
console.warn('WARNING: LoadError: ' + message);
}
}
return true;
}
function require(path) {
if (require_table[path]) {
return false;
}
return load(path);
}
Opal.modules = modules;
Opal.loaded_features = loaded_features;
Opal.normalize_loadable_path = normalize_loadable_path;
Opal.mark_as_loaded = mark_as_loaded;
Opal.load = load;
Opal.require = require;
})(Opal);
// Initialization
// --------------
// The actual class for BasicObject
var BasicObjectClass;
// The actual Object class
var ObjectClass;
// The actual Module class
var ModuleClass;
// The actual Class class
var ClassClass;
// Constructor for instances of BasicObject
function BasicObject(){}
// Constructor for instances of Object
function Object(){}
// Constructor for instances of Class
function Class(){}
// Constructor for instances of Module
function Module(){}
// Constructor for instances of NilClass (nil)
function NilClass(){}
// Constructors for *instances* of core objects
boot_class_alloc('BasicObject', BasicObject);
boot_class_alloc('Object', Object, BasicObject);
boot_class_alloc('Module', Module, Object);
boot_class_alloc('Class', Class, Module);
// Constructors for *classes* of core objects
BasicObjectClass = boot_core_class_object('BasicObject', BasicObject, Class);
ObjectClass = boot_core_class_object('Object', Object, BasicObjectClass.constructor);
ModuleClass = boot_core_class_object('Module', Module, ObjectClass.constructor);
ClassClass = boot_core_class_object('Class', Class, ModuleClass.constructor);
// Fix booted classes to use their metaclass
BasicObjectClass.$$class = ClassClass;
ObjectClass.$$class = ClassClass;
ModuleClass.$$class = ClassClass;
ClassClass.$$class = ClassClass;
// Fix superclasses of booted classes
BasicObjectClass.$$super = null;
ObjectClass.$$super = BasicObjectClass;
ModuleClass.$$super = ObjectClass;
ClassClass.$$super = ModuleClass;
BasicObjectClass.$$parent = null;
ObjectClass.$$parent = BasicObjectClass;
ModuleClass.$$parent = ObjectClass;
ClassClass.$$parent = ModuleClass;
// Internally, Object acts like a module as it is "included" into bridged
// classes. In other words, we donate methods from Object into our bridged
// classes as their prototypes don't inherit from our root Object, so they
// act like module includes.
ObjectClass.$$dep = bridged_classes;
Opal.base = ObjectClass;
BasicObjectClass.$$scope = ObjectClass.$$scope = Opal;
BasicObjectClass.$$orig_scope = ObjectClass.$$orig_scope = Opal;
Opal.Kernel = ObjectClass;
ModuleClass.$$scope = ObjectClass.$$scope;
ModuleClass.$$orig_scope = ObjectClass.$$orig_scope;
ClassClass.$$scope = ObjectClass.$$scope;
ClassClass.$$orig_scope = ObjectClass.$$orig_scope;
ObjectClass.$$proto.toString = function() {
return this.$to_s();
};
ObjectClass.$$proto.$require = Opal.require;
Opal.top = new ObjectClass.$$alloc();
// Nil
var nil_id = Opal.uid(); // nil id is traditionally 4
Opal.klass(ObjectClass, ObjectClass, 'NilClass', NilClass);
var nil = Opal.nil = new NilClass();
nil.$$id = nil_id;
nil.call = nil.apply = function() { throw Opal.LocalJumpError.$new('no block given'); };
Opal.breaker = new Error('unexpected break');
Opal.returner = new Error('unexpected return');
bridge_class('Array', Array);
bridge_class('Boolean', Boolean);
bridge_class('Numeric', Number);
bridge_class('String', String);
bridge_class('Proc', Function);
bridge_class('Exception', Error);
bridge_class('Regexp', RegExp);
bridge_class('Time', Date);
TypeError.$$super = Error;
}).call(this);
if (typeof(global) !== 'undefined') {
global.Opal = this.Opal;
Opal.global = global;
}
if (typeof(window) !== 'undefined') {
window.Opal = this.Opal;
Opal.global = window;
}
Opal.mark_as_loaded(Opal.normalize_loadable_path("corelib/runtime"));
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/helpers"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module;
Opal.add_stubs(['$new', '$class', '$===', '$respond_to?', '$raise', '$type_error', '$__send__', '$coerce_to', '$nil?', '$<=>', '$inspect']);
return (function($base) {
var self = $module($base, 'Opal');
var def = self.$$proto, $scope = self.$$scope;
Opal.defs(self, '$type_error', function(object, type, method, coerced) {
var $a, $b, self = this;
if (method == null) {
method = nil
}
if (coerced == null) {
coerced = nil
}
if ((($a = (($b = method !== false && method !== nil) ? coerced : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return $scope.get('TypeError').$new("can't convert " + (object.$class()) + " into " + (type) + " (" + (object.$class()) + "#" + (method) + " gives " + (coerced.$class()))
} else {
return $scope.get('TypeError').$new("no implicit conversion of " + (object.$class()) + " into " + (type))
};
});
Opal.defs(self, '$coerce_to', function(object, type, method) {
var $a, self = this;
if ((($a = type['$==='](object)) !== nil && (!$a.$$is_boolean || $a == true))) {
return object};
if ((($a = object['$respond_to?'](method)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise(self.$type_error(object, type))
};
return object.$__send__(method);
});
Opal.defs(self, '$coerce_to!', function(object, type, method) {
var $a, self = this, coerced = nil;
coerced = self.$coerce_to(object, type, method);
if ((($a = type['$==='](coerced)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise(self.$type_error(object, type, method, coerced))
};
return coerced;
});
Opal.defs(self, '$coerce_to?', function(object, type, method) {
var $a, self = this, coerced = nil;
if ((($a = object['$respond_to?'](method)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return nil
};
coerced = self.$coerce_to(object, type, method);
if ((($a = coerced['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil};
if ((($a = type['$==='](coerced)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise(self.$type_error(object, type, method, coerced))
};
return coerced;
});
Opal.defs(self, '$try_convert', function(object, type, method) {
var $a, self = this;
if ((($a = type['$==='](object)) !== nil && (!$a.$$is_boolean || $a == true))) {
return object};
if ((($a = object['$respond_to?'](method)) !== nil && (!$a.$$is_boolean || $a == true))) {
return object.$__send__(method)
} else {
return nil
};
});
Opal.defs(self, '$compare', function(a, b) {
var $a, self = this, compare = nil;
compare = a['$<=>'](b);
if ((($a = compare === nil) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "comparison of " + (a.$class()) + " with " + (b.$class()) + " failed")};
return compare;
});
Opal.defs(self, '$destructure', function(args) {
var self = this;
if (args.length == 1) {
return args[0];
}
else if (args.$$is_array) {
return args;
}
else {
return $slice.call(args);
}
});
Opal.defs(self, '$respond_to?', function(obj, method) {
var self = this;
if (obj == null || !obj.$$class) {
return false;
}
return obj['$respond_to?'](method);
});
Opal.defs(self, '$inspect', function(obj) {
var self = this;
if (obj === undefined) {
return "undefined";
}
else if (obj === null) {
return "null";
}
else if (!obj.$$class) {
return obj.toString();
}
else {
return obj.$inspect();
}
});
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/module"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$attr_reader', '$attr_writer', '$coerce_to!', '$raise', '$=~', '$const_missing', '$const_get', '$to_str', '$to_proc', '$append_features', '$included', '$name', '$new', '$to_s', '$__id__']);
return (function($base, $super) {
function $Module(){};
var self = $Module = $klass($base, $super, 'Module', $Module);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4;
Opal.defs(self, '$new', TMP_1 = function() {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
TMP_1.$$p = null;
function AnonModule(){}
var klass = Opal.boot(Opal.Module, AnonModule);
klass.$$name = nil;
klass.$$class = Opal.Module;
klass.$$dep = []
klass.$$is_mod = true;
klass.$$proto = {};
// inherit scope from parent
Opal.create_scope(Opal.Module.$$scope, klass);
if (block !== nil) {
var block_self = block.$$s;
block.$$s = null;
block.call(klass);
block.$$s = block_self;
}
return klass;
});
def['$==='] = function(object) {
var $a, self = this;
if ((($a = object == null) !== nil && (!$a.$$is_boolean || $a == true))) {
return false};
return Opal.is_a(object, self);
};
def['$<'] = function(other) {
var self = this;
var working = self;
while (working) {
if (working === other) {
return true;
}
working = working.$$parent;
}
return false;
};
def.$alias_method = function(newname, oldname) {
var self = this;
var newjsid = '$' + newname,
body = self.$$proto['$' + oldname];
if (self.$$is_singleton) {
self.$$proto[newjsid] = body;
}
else {
Opal.defn(self, newjsid, body);
}
return self;
return self;
};
def.$alias_native = function(mid, jsid) {
var self = this;
if (jsid == null) {
jsid = mid
}
return self.$$proto['$' + mid] = self.$$proto[jsid];
};
def.$ancestors = function() {
var self = this;
var parent = self,
result = [];
while (parent) {
result.push(parent);
result = result.concat(parent.$$inc);
parent = parent.$$super;
}
return result;
};
def.$append_features = function(klass) {
var self = this;
Opal.append_features(self, klass);
return self;
};
def.$attr_accessor = function(names) {
var $a, $b, self = this;
names = $slice.call(arguments, 0);
($a = self).$attr_reader.apply($a, [].concat(names));
return ($b = self).$attr_writer.apply($b, [].concat(names));
};
def.$attr_reader = function(names) {
var self = this;
names = $slice.call(arguments, 0);
for (var i = 0, length = names.length; i < length; i++) {
(function(name) {
self.$$proto[name] = nil;
var func = function() { return this[name] };
if (self.$$is_singleton) {
self.$$proto.constructor.prototype['$' + name] = func;
}
else {
Opal.defn(self, '$' + name, func);
}
})(names[i]);
}
return nil;
};
def.$attr_writer = function(names) {
var self = this;
names = $slice.call(arguments, 0);
for (var i = 0, length = names.length; i < length; i++) {
(function(name) {
self.$$proto[name] = nil;
var func = function(value) { return this[name] = value; };
if (self.$$is_singleton) {
self.$$proto.constructor.prototype['$' + name + '='] = func;
}
else {
Opal.defn(self, '$' + name + '=', func);
}
})(names[i]);
}
return nil;
};
Opal.defn(self, '$attr', def.$attr_accessor);
def.$autoload = function(const$, path) {
var self = this;
var autoloaders;
if (!(autoloaders = self.$$autoload)) {
autoloaders = self.$$autoload = {};
}
autoloaders[const$] = path;
return nil;
;
};
def.$class_variable_get = function(name) {
var $a, self = this;
name = $scope.get('Opal')['$coerce_to!'](name, $scope.get('String'), "to_str");
if ((($a = name.length < 3 || name.slice(0,2) !== '@@') !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('NameError'), "class vars should start with @@")};
var value = Opal.cvars[name.slice(2)];
(function() {if ((($a = value == null) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.$raise($scope.get('NameError'), "uninitialized class variable @@a in")
} else {
return nil
}; return nil; })()
return value;
};
def.$class_variable_set = function(name, value) {
var $a, self = this;
name = $scope.get('Opal')['$coerce_to!'](name, $scope.get('String'), "to_str");
if ((($a = name.length < 3 || name.slice(0,2) !== '@@') !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('NameError'))};
Opal.cvars[name.slice(2)] = value;
return value;
};
def.$constants = function() {
var self = this;
return self.$$scope.constants;
};
def['$const_defined?'] = function(name, inherit) {
var $a, self = this;
if (inherit == null) {
inherit = true
}
if ((($a = name['$=~'](/^[A-Z]\w*$/)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('NameError'), "wrong constant name " + (name))
};
scopes = [self.$$scope];
if (inherit || self === Opal.Object) {
var parent = self.$$super;
while (parent !== Opal.BasicObject) {
scopes.push(parent.$$scope);
parent = parent.$$super;
}
}
for (var i = 0, len = scopes.length; i < len; i++) {
if (scopes[i].hasOwnProperty(name)) {
return true;
}
}
return false;
};
def.$const_get = function(name, inherit) {
var $a, self = this;
if (inherit == null) {
inherit = true
}
if ((($a = name['$=~'](/^[A-Z]\w*$/)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('NameError'), "wrong constant name " + (name))
};
var scopes = [self.$$scope];
if (inherit || self == Opal.Object) {
var parent = self.$$super;
while (parent !== Opal.BasicObject) {
scopes.push(parent.$$scope);
parent = parent.$$super;
}
}
for (var i = 0, len = scopes.length; i < len; i++) {
if (scopes[i].hasOwnProperty(name)) {
return scopes[i][name];
}
}
return self.$const_missing(name);
};
def.$const_missing = function(const$) {
var self = this;
if (self.$$autoload) {
var file = self.$$autoload[const$];
if (file) {
self.$require(file);
return self.$const_get(const$);
}
}
;
return self.$raise($scope.get('NameError'), "uninitialized constant " + (self) + "::" + (const$));
};
def.$const_set = function(name, value) {
var $a, self = this;
if ((($a = name['$=~'](/^[A-Z]\w*$/)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('NameError'), "wrong constant name " + (name))
};
try {
name = name.$to_str()
} catch ($err) {if (true) {
self.$raise($scope.get('TypeError'), "conversion with #to_str failed")
}else { throw $err; }
};
Opal.casgn(self, name, value);
return value;
};
def.$define_method = TMP_2 = function(name, method) {
var self = this, $iter = TMP_2.$$p, block = $iter || nil;
TMP_2.$$p = null;
if (method) {
block = method.$to_proc();
}
if (block === nil) {
throw new Error("no block given");
}
var jsid = '$' + name;
block.$$jsid = name;
block.$$s = null;
block.$$def = block;
if (self.$$is_singleton) {
self.$$proto[jsid] = block;
}
else {
Opal.defn(self, jsid, block);
}
return name;
;
};
def.$remove_method = function(name) {
var self = this;
var jsid = '$' + name;
var current = self.$$proto[jsid];
delete self.$$proto[jsid];
// Check if we need to reverse Opal.donate
// Opal.retire(self, [jsid]);
return self;
};
def.$include = function(mods) {
var self = this;
mods = $slice.call(arguments, 0);
for (var i = mods.length - 1; i >= 0; i--) {
var mod = mods[i];
if (mod === self) {
continue;
}
(mod).$append_features(self);
(mod).$included(self);
}
return self;
};
def['$include?'] = function(mod) {
var self = this;
for (var cls = self; cls; cls = cls.parent) {
for (var i = 0; i != cls.$$inc.length; i++) {
var mod2 = cls.$$inc[i];
if (mod === mod2) {
return true;
}
}
}
return false;
};
def.$instance_method = function(name) {
var self = this;
var meth = self.$$proto['$' + name];
if (!meth || meth.$$stub) {
self.$raise($scope.get('NameError'), "undefined method `" + (name) + "' for class `" + (self.$name()) + "'");
}
return $scope.get('UnboundMethod').$new(self, meth, name);
};
def.$instance_methods = function(include_super) {
var self = this;
if (include_super == null) {
include_super = false
}
var methods = [],
proto = self.$$proto;
for (var prop in proto) {
if (!prop.charAt(0) === '$') {
continue;
}
if (typeof(proto[prop]) !== "function") {
continue;
}
if (proto[prop].$$stub) {
continue;
}
if (!self.$$is_mod) {
if (self !== Opal.BasicObject && proto[prop] === Opal.BasicObject.$$proto[prop]) {
continue;
}
if (!include_super && !proto.hasOwnProperty(prop)) {
continue;
}
if (!include_super && proto[prop].$$donated) {
continue;
}
}
methods.push(prop.substr(1));
}
return methods;
};
def.$included = function(mod) {
var self = this;
return nil;
};
def.$extended = function(mod) {
var self = this;
return nil;
};
def.$module_eval = TMP_3 = function() {
var self = this, $iter = TMP_3.$$p, block = $iter || nil;
TMP_3.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "no block given")
};
var old = block.$$s,
result;
block.$$s = null;
result = block.call(self);
block.$$s = old;
return result;
};
Opal.defn(self, '$class_eval', def.$module_eval);
def.$module_exec = TMP_4 = function() {
var self = this, $iter = TMP_4.$$p, block = $iter || nil;
TMP_4.$$p = null;
if (block === nil) {
throw new Error("no block given");
}
var block_self = block.$$s, result;
block.$$s = null;
result = block.apply(self, $slice.call(arguments));
block.$$s = block_self;
return result;
};
Opal.defn(self, '$class_exec', def.$module_exec);
def['$method_defined?'] = function(method) {
var self = this;
var body = self.$$proto['$' + method];
return (!!body) && !body.$$stub;
};
def.$module_function = function(methods) {
var self = this;
methods = $slice.call(arguments, 0);
if (methods.length === 0) {
self.$$module_function = true;
}
else {
for (var i = 0, length = methods.length; i < length; i++) {
var meth = methods[i], func = self.$$proto['$' + meth];
self.constructor.prototype['$' + meth] = func;
}
}
return self;
};
def.$name = function() {
var self = this;
if (self.$$full_name) {
return self.$$full_name;
}
var result = [], base = self;
while (base) {
if (base.$$name === nil) {
return result.length === 0 ? nil : result.join('::');
}
result.unshift(base.$$name);
base = base.$$base_module;
if (base === Opal.Object) {
break;
}
}
if (result.length === 0) {
return nil;
}
return self.$$full_name = result.join('::');
};
def.$public = function(methods) {
var self = this;
methods = $slice.call(arguments, 0);
if (methods.length === 0) {
self.$$module_function = false;
}
return nil;
};
Opal.defn(self, '$private', def.$public);
Opal.defn(self, '$protected', def.$public);
Opal.defn(self, '$nesting', def.$public);
def.$private_class_method = function(name) {
var self = this;
return self['$' + name] || nil;
};
Opal.defn(self, '$public_class_method', def.$private_class_method);
def['$private_method_defined?'] = function(obj) {
var self = this;
return false;
};
def.$private_constant = function() {
var self = this;
return nil;
};
Opal.defn(self, '$protected_method_defined?', def['$private_method_defined?']);
Opal.defn(self, '$public_instance_methods', def.$instance_methods);
Opal.defn(self, '$public_method_defined?', def['$method_defined?']);
def.$remove_class_variable = function() {
var self = this;
return nil;
};
def.$remove_const = function(name) {
var self = this;
var old = self.$$scope[name];
delete self.$$scope[name];
return old;
};
def.$to_s = function() {
var $a, self = this;
return ((($a = self.$name()) !== false && $a !== nil) ? $a : "#<" + (self.$$is_mod ? 'Module' : 'Class') + ":0x" + (self.$__id__().$to_s(16)) + ">");
};
return (def.$undef_method = function(symbol) {
var self = this;
Opal.add_stub_for(self.$$proto, "$" + symbol);
return self;
}, nil) && 'undef_method';
})(self, null)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/class"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$require', '$raise', '$allocate']);
self.$require("corelib/module");
return (function($base, $super) {
function $Class(){};
var self = $Class = $klass($base, $super, 'Class', $Class);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2;
Opal.defs(self, '$new', TMP_1 = function(sup) {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
if (sup == null) {
sup = $scope.get('Object')
}
TMP_1.$$p = null;
if (!sup.$$is_class || sup.$$is_mod) {
self.$raise($scope.get('TypeError'), "superclass must be a Class");
}
function AnonClass(){};
var klass = Opal.boot(sup, AnonClass)
klass.$$name = nil;
klass.$$parent = sup;
// inherit scope from parent
Opal.create_scope(sup.$$scope, klass);
sup.$inherited(klass);
if (block !== nil) {
var block_self = block.$$s;
block.$$s = null;
block.call(klass);
block.$$s = block_self;
}
return klass;
;
});
def.$allocate = function() {
var self = this;
var obj = new self.$$alloc;
obj.$$id = Opal.uid();
return obj;
};
def.$inherited = function(cls) {
var self = this;
return nil;
};
def.$new = TMP_2 = function(args) {
var self = this, $iter = TMP_2.$$p, block = $iter || nil;
args = $slice.call(arguments, 0);
TMP_2.$$p = null;
var obj = self.$allocate();
obj.$initialize.$$p = block;
obj.$initialize.apply(obj, args);
return obj;
;
};
return (def.$superclass = function() {
var self = this;
return self.$$super || nil;
}, nil) && 'superclass';
})(self, null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/basic_object"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$raise', '$inspect']);
return (function($base, $super) {
function $BasicObject(){};
var self = $BasicObject = $klass($base, $super, 'BasicObject', $BasicObject);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4;
Opal.defn(self, '$initialize', function() {
var self = this;
return nil;
});
Opal.defn(self, '$==', function(other) {
var self = this;
return self === other;
});
Opal.defn(self, '$__id__', function() {
var self = this;
return self.$$id || (self.$$id = Opal.uid());
});
Opal.defn(self, '$__send__', TMP_1 = function(symbol, args) {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
args = $slice.call(arguments, 1);
TMP_1.$$p = null;
var func = self['$' + symbol]
if (func) {
if (block !== nil) {
func.$$p = block;
}
return func.apply(self, args);
}
if (block !== nil) {
self.$method_missing.$$p = block;
}
return self.$method_missing.apply(self, [symbol].concat(args));
});
Opal.defn(self, '$!', function() {
var self = this;
return false;
});
Opal.defn(self, '$eql?', def['$==']);
Opal.defn(self, '$equal?', def['$==']);
Opal.defn(self, '$instance_eval', TMP_2 = function() {
var self = this, $iter = TMP_2.$$p, block = $iter || nil;
TMP_2.$$p = null;
if (block !== false && block !== nil) {
} else {
$scope.get('Kernel').$raise($scope.get('ArgumentError'), "no block given")
};
var old = block.$$s,
result;
block.$$s = null;
result = block.call(self, self);
block.$$s = old;
return result;
});
Opal.defn(self, '$instance_exec', TMP_3 = function(args) {
var self = this, $iter = TMP_3.$$p, block = $iter || nil;
args = $slice.call(arguments, 0);
TMP_3.$$p = null;
if (block !== false && block !== nil) {
} else {
$scope.get('Kernel').$raise($scope.get('ArgumentError'), "no block given")
};
var block_self = block.$$s,
result;
block.$$s = null;
result = block.apply(self, args);
block.$$s = block_self;
return result;
});
return (Opal.defn(self, '$method_missing', TMP_4 = function(symbol, args) {
var $a, self = this, $iter = TMP_4.$$p, block = $iter || nil;
args = $slice.call(arguments, 1);
TMP_4.$$p = null;
return $scope.get('Kernel').$raise($scope.get('NoMethodError'), (function() {if ((($a = self.$inspect && !self.$inspect.$$stub) !== nil && (!$a.$$is_boolean || $a == true))) {
return "undefined method `" + (symbol) + "' for " + (self.$inspect()) + ":" + (self.$$class)
} else {
return "undefined method `" + (symbol) + "' for " + (self.$$class)
}; return nil; })());
}), nil) && 'method_missing';
})(self, null)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/kernel"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $gvars = Opal.gvars;
Opal.add_stubs(['$raise', '$inspect', '$==', '$class', '$new', '$respond_to?', '$to_ary', '$to_a', '$<<', '$allocate', '$copy_instance_variables', '$initialize_clone', '$initialize_copy', '$singleton_class', '$initialize_dup', '$for', '$to_proc', '$each', '$reverse', '$append_features', '$extended', '$to_i', '$to_s', '$to_f', '$*', '$__id__', '$===', '$empty?', '$ArgumentError', '$nan?', '$infinite?', '$to_int', '$coerce_to!', '$>', '$length', '$print', '$format', '$puts', '$<=', '$[]', '$nil?', '$is_a?', '$rand', '$coerce_to', '$respond_to_missing?', '$try_convert!', '$expand_path', '$join', '$start_with?']);
return (function($base) {
var self = $module($base, 'Kernel');
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_6, TMP_7, TMP_8, TMP_10;
Opal.defn(self, '$method_missing', TMP_1 = function(symbol, args) {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
args = $slice.call(arguments, 1);
TMP_1.$$p = null;
return self.$raise($scope.get('NoMethodError'), "undefined method `" + (symbol) + "' for " + (self.$inspect()));
});
Opal.defn(self, '$=~', function(obj) {
var self = this;
return false;
});
Opal.defn(self, '$===', function(other) {
var self = this;
return self['$=='](other);
});
Opal.defn(self, '$<=>', function(other) {
var self = this;
if (self['$=='](other)) {
return 0;
}
return nil;
;
});
Opal.defn(self, '$method', function(name) {
var self = this;
var meth = self['$' + name];
if (!meth || meth.$$stub) {
self.$raise($scope.get('NameError'), "undefined method `" + (name) + "' for class `" + (self.$class()) + "'");
}
return $scope.get('Method').$new(self, meth, name);
});
Opal.defn(self, '$methods', function(all) {
var self = this;
if (all == null) {
all = true
}
var methods = [];
for (var key in self) {
if (key[0] == "$" && typeof(self[key]) === "function") {
if (all == false || all === nil) {
if (!Opal.hasOwnProperty.call(self, key)) {
continue;
}
}
if (self[key].$$stub === undefined) {
methods.push(key.substr(1));
}
}
}
return methods;
});
Opal.defn(self, '$Array', TMP_2 = function(object, args) {
var self = this, $iter = TMP_2.$$p, block = $iter || nil;
args = $slice.call(arguments, 1);
TMP_2.$$p = null;
if (object == null || object === nil) {
return [];
}
else if (object['$respond_to?']("to_ary")) {
return object.$to_ary();
}
else if (object['$respond_to?']("to_a")) {
return object.$to_a();
}
else {
return [object];
}
;
});
Opal.defn(self, '$at_exit', TMP_3 = function() {
var $a, self = this, $iter = TMP_3.$$p, block = $iter || nil;
if ($gvars.__at_exit__ == null) $gvars.__at_exit__ = nil;
TMP_3.$$p = null;
((($a = $gvars.__at_exit__) !== false && $a !== nil) ? $a : $gvars.__at_exit__ = []);
return $gvars.__at_exit__['$<<'](block);
});
Opal.defn(self, '$caller', function() {
var self = this;
return [];
});
Opal.defn(self, '$class', function() {
var self = this;
return self.$$class;
});
Opal.defn(self, '$copy_instance_variables', function(other) {
var self = this;
for (var name in other) {
if (name.charAt(0) !== '$') {
self[name] = other[name];
}
}
});
Opal.defn(self, '$clone', function() {
var self = this, copy = nil;
copy = self.$class().$allocate();
copy.$copy_instance_variables(self);
copy.$initialize_clone(self);
return copy;
});
Opal.defn(self, '$initialize_clone', function(other) {
var self = this;
return self.$initialize_copy(other);
});
Opal.defn(self, '$define_singleton_method', TMP_4 = function(name) {
var self = this, $iter = TMP_4.$$p, body = $iter || nil;
TMP_4.$$p = null;
if (body !== false && body !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to create Proc object without a block")
};
var jsid = '$' + name;
body.$$jsid = name;
body.$$s = null;
body.$$def = body;
self.$singleton_class().$$proto[jsid] = body;
return self;
});
Opal.defn(self, '$dup', function() {
var self = this, copy = nil;
copy = self.$class().$allocate();
copy.$copy_instance_variables(self);
copy.$initialize_dup(self);
return copy;
});
Opal.defn(self, '$initialize_dup', function(other) {
var self = this;
return self.$initialize_copy(other);
});
Opal.defn(self, '$enum_for', TMP_5 = function(method, args) {
var $a, $b, self = this, $iter = TMP_5.$$p, block = $iter || nil;
args = $slice.call(arguments, 1);
if (method == null) {
method = "each"
}
TMP_5.$$p = null;
return ($a = ($b = $scope.get('Enumerator')).$for, $a.$$p = block.$to_proc(), $a).apply($b, [self, method].concat(args));
});
Opal.defn(self, '$to_enum', def.$enum_for);
Opal.defn(self, '$equal?', function(other) {
var self = this;
return self === other;
});
Opal.defn(self, '$exit', function(status) {
var $a, $b, self = this;
if ($gvars.__at_exit__ == null) $gvars.__at_exit__ = nil;
if (status == null) {
status = true
}
if ((($a = $gvars.__at_exit__) !== nil && (!$a.$$is_boolean || $a == true))) {
($a = ($b = $gvars.__at_exit__.$reverse()).$each, $a.$$p = "call".$to_proc(), $a).call($b)};
if ((($a = status === true) !== nil && (!$a.$$is_boolean || $a == true))) {
status = 0};
Opal.exit(status);
return nil;
});
Opal.defn(self, '$extend', function(mods) {
var self = this;
mods = $slice.call(arguments, 0);
var singleton = self.$singleton_class();
for (var i = mods.length - 1; i >= 0; i--) {
var mod = mods[i];
(mod).$append_features(singleton);
(mod).$extended(self);
}
;
return self;
});
Opal.defn(self, '$format', function(format, args) {
var self = this;
args = $slice.call(arguments, 1);
var idx = 0;
return format.replace(/%(\d+\$)?([-+ 0]*)(\d*|\*(\d+\$)?)(?:\.(\d*|\*(\d+\$)?))?([cspdiubBoxXfgeEG])|(%%)/g, function(str, idx_str, flags, width_str, w_idx_str, prec_str, p_idx_str, spec, escaped) {
if (escaped) {
return '%';
}
var width,
prec,
is_integer_spec = ("diubBoxX".indexOf(spec) != -1),
is_float_spec = ("eEfgG".indexOf(spec) != -1),
prefix = '',
obj;
if (width_str === undefined) {
width = undefined;
} else if (width_str.charAt(0) == '*') {
var w_idx = idx++;
if (w_idx_str) {
w_idx = parseInt(w_idx_str, 10) - 1;
}
width = (args[w_idx]).$to_i();
} else {
width = parseInt(width_str, 10);
}
if (!prec_str) {
prec = is_float_spec ? 6 : undefined;
} else if (prec_str.charAt(0) == '*') {
var p_idx = idx++;
if (p_idx_str) {
p_idx = parseInt(p_idx_str, 10) - 1;
}
prec = (args[p_idx]).$to_i();
} else {
prec = parseInt(prec_str, 10);
}
if (idx_str) {
idx = parseInt(idx_str, 10) - 1;
}
switch (spec) {
case 'c':
obj = args[idx];
if (obj.$$is_string) {
str = obj.charAt(0);
} else {
str = String.fromCharCode((obj).$to_i());
}
break;
case 's':
str = (args[idx]).$to_s();
if (prec !== undefined) {
str = str.substr(0, prec);
}
break;
case 'p':
str = (args[idx]).$inspect();
if (prec !== undefined) {
str = str.substr(0, prec);
}
break;
case 'd':
case 'i':
case 'u':
str = (args[idx]).$to_i().toString();
break;
case 'b':
case 'B':
str = (args[idx]).$to_i().toString(2);
break;
case 'o':
str = (args[idx]).$to_i().toString(8);
break;
case 'x':
case 'X':
str = (args[idx]).$to_i().toString(16);
break;
case 'e':
case 'E':
str = (args[idx]).$to_f().toExponential(prec);
break;
case 'f':
str = (args[idx]).$to_f().toFixed(prec);
break;
case 'g':
case 'G':
str = (args[idx]).$to_f().toPrecision(prec);
break;
}
idx++;
if (is_integer_spec || is_float_spec) {
if (str.charAt(0) == '-') {
prefix = '-';
str = str.substr(1);
} else {
if (flags.indexOf('+') != -1) {
prefix = '+';
} else if (flags.indexOf(' ') != -1) {
prefix = ' ';
}
}
}
if (is_integer_spec && prec !== undefined) {
if (str.length < prec) {
str = "0"['$*'](prec - str.length) + str;
}
}
var total_len = prefix.length + str.length;
if (width !== undefined && total_len < width) {
if (flags.indexOf('-') != -1) {
str = str + " "['$*'](width - total_len);
} else {
var pad_char = ' ';
if (flags.indexOf('0') != -1) {
str = "0"['$*'](width - total_len) + str;
} else {
prefix = " "['$*'](width - total_len) + prefix;
}
}
}
var result = prefix + str;
if ('XEG'.indexOf(spec) != -1) {
result = result.toUpperCase();
}
return result;
});
});
Opal.defn(self, '$freeze', function() {
var self = this;
self.___frozen___ = true;
return self;
});
Opal.defn(self, '$frozen?', function() {
var $a, self = this;
if (self.___frozen___ == null) self.___frozen___ = nil;
return ((($a = self.___frozen___) !== false && $a !== nil) ? $a : false);
});
Opal.defn(self, '$hash', function() {
var self = this;
return [self.$$class.$$name,(self.$$class).$__id__(),self.$__id__()].join(':');
});
Opal.defn(self, '$initialize_copy', function(other) {
var self = this;
return nil;
});
Opal.defn(self, '$inspect', function() {
var self = this;
return self.$to_s();
});
Opal.defn(self, '$instance_of?', function(klass) {
var self = this;
return self.$$class === klass;
});
Opal.defn(self, '$instance_variable_defined?', function(name) {
var self = this;
return Opal.hasOwnProperty.call(self, name.substr(1));
});
Opal.defn(self, '$instance_variable_get', function(name) {
var self = this;
var ivar = self[name.substr(1)];
return ivar == null ? nil : ivar;
});
Opal.defn(self, '$instance_variable_set', function(name, value) {
var self = this;
return self[name.substr(1)] = value;
});
Opal.defn(self, '$instance_variables', function() {
var self = this;
var result = [];
for (var name in self) {
if (name.charAt(0) !== '$') {
if (name !== '$$class' && name !== '$$id') {
result.push('@' + name);
}
}
}
return result;
});
Opal.defn(self, '$Integer', function(value, base) {
var $a, $b, self = this, $case = nil;
if (base == null) {
base = nil
}
if ((($a = $scope.get('String')['$==='](value)) !== nil && (!$a.$$is_boolean || $a == true))) {
if ((($a = value['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "invalid value for Integer: (empty string)")};
return parseInt(value, ((($a = base) !== false && $a !== nil) ? $a : undefined));};
if (base !== false && base !== nil) {
self.$raise(self.$ArgumentError("base is only valid for String values"))};
return (function() {$case = value;if ($scope.get('Integer')['$===']($case)) {return value}else if ($scope.get('Float')['$===']($case)) {if ((($a = ((($b = value['$nan?']()) !== false && $b !== nil) ? $b : value['$infinite?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('FloatDomainError'), "unable to coerce " + (value) + " to Integer")};
return value.$to_int();}else if ($scope.get('NilClass')['$===']($case)) {return self.$raise($scope.get('TypeError'), "can't convert nil into Integer")}else {if ((($a = value['$respond_to?']("to_int")) !== nil && (!$a.$$is_boolean || $a == true))) {
return value.$to_int()
} else if ((($a = value['$respond_to?']("to_i")) !== nil && (!$a.$$is_boolean || $a == true))) {
return value.$to_i()
} else {
return self.$raise($scope.get('TypeError'), "can't convert " + (value.$class()) + " into Integer")
}}})();
});
Opal.defn(self, '$Float', function(value) {
var $a, self = this;
if ((($a = $scope.get('String')['$==='](value)) !== nil && (!$a.$$is_boolean || $a == true))) {
return parseFloat(value);
} else if ((($a = value['$respond_to?']("to_f")) !== nil && (!$a.$$is_boolean || $a == true))) {
return value.$to_f()
} else {
return self.$raise($scope.get('TypeError'), "can't convert " + (value.$class()) + " into Float")
};
});
Opal.defn(self, '$is_a?', function(klass) {
var self = this;
return Opal.is_a(self, klass);
});
Opal.defn(self, '$kind_of?', def['$is_a?']);
Opal.defn(self, '$lambda', TMP_6 = function() {
var self = this, $iter = TMP_6.$$p, block = $iter || nil;
TMP_6.$$p = null;
block.$$is_lambda = true;
return block;
});
Opal.defn(self, '$load', function(file) {
var self = this;
file = $scope.get('Opal')['$coerce_to!'](file, $scope.get('String'), "to_str");
return Opal.load(Opal.normalize_loadable_path(file));
});
Opal.defn(self, '$loop', TMP_7 = function() {
var self = this, $iter = TMP_7.$$p, block = $iter || nil;
TMP_7.$$p = null;
while (true) {
if (block() === $breaker) {
return $breaker.$v;
}
}
return self;
});
Opal.defn(self, '$nil?', function() {
var self = this;
return false;
});
Opal.defn(self, '$object_id', def.$__id__);
Opal.defn(self, '$printf', function(args) {
var $a, self = this;
args = $slice.call(arguments, 0);
if (args.$length()['$>'](0)) {
self.$print(($a = self).$format.apply($a, [].concat(args)))};
return nil;
});
Opal.defn(self, '$private_methods', function() {
var self = this;
return [];
});
Opal.defn(self, '$private_instance_methods', def.$private_methods);
Opal.defn(self, '$proc', TMP_8 = function() {
var self = this, $iter = TMP_8.$$p, block = $iter || nil;
TMP_8.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to create Proc object without a block")
};
block.$$is_lambda = false;
return block;
});
Opal.defn(self, '$puts', function(strs) {
var $a, self = this;
if ($gvars.stdout == null) $gvars.stdout = nil;
strs = $slice.call(arguments, 0);
return ($a = $gvars.stdout).$puts.apply($a, [].concat(strs));
});
Opal.defn(self, '$p', function(args) {
var $a, $b, TMP_9, self = this;
args = $slice.call(arguments, 0);
($a = ($b = args).$each, $a.$$p = (TMP_9 = function(obj){var self = TMP_9.$$s || this;
if ($gvars.stdout == null) $gvars.stdout = nil;
if (obj == null) obj = nil;
return $gvars.stdout.$puts(obj.$inspect())}, TMP_9.$$s = self, TMP_9), $a).call($b);
if (args.$length()['$<='](1)) {
return args['$[]'](0)
} else {
return args
};
});
Opal.defn(self, '$print', function(strs) {
var $a, self = this;
if ($gvars.stdout == null) $gvars.stdout = nil;
strs = $slice.call(arguments, 0);
return ($a = $gvars.stdout).$print.apply($a, [].concat(strs));
});
Opal.defn(self, '$warn', function(strs) {
var $a, $b, self = this;
if ($gvars.VERBOSE == null) $gvars.VERBOSE = nil;
if ($gvars.stderr == null) $gvars.stderr = nil;
strs = $slice.call(arguments, 0);
if ((($a = ((($b = $gvars.VERBOSE['$nil?']()) !== false && $b !== nil) ? $b : strs['$empty?']())) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil
} else {
return ($a = $gvars.stderr).$puts.apply($a, [].concat(strs))
};
});
Opal.defn(self, '$raise', function(exception, string) {
var self = this;
if ($gvars["!"] == null) $gvars["!"] = nil;
if (exception == null && $gvars["!"]) {
exception = $gvars["!"];
}
else if (exception.$$is_string) {
exception = $scope.get('RuntimeError').$new(exception);
}
else if (!exception['$is_a?']($scope.get('Exception'))) {
exception = exception.$new(string);
}
$gvars["!"] = exception;
throw exception;
;
});
Opal.defn(self, '$fail', def.$raise);
Opal.defn(self, '$rand', function(max) {
var self = this;
if (max === undefined) {
return Math.random();
}
else if (max.$$is_range) {
var arr = max.$to_a();
return arr[self.$rand(arr.length)];
}
else {
return Math.floor(Math.random() *
Math.abs($scope.get('Opal').$coerce_to(max, $scope.get('Integer'), "to_int")));
}
});
Opal.defn(self, '$respond_to?', function(name, include_all) {
var $a, self = this;
if (include_all == null) {
include_all = false
}
if ((($a = self['$respond_to_missing?'](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
var body = self['$' + name];
if (typeof(body) === "function" && !body.$$stub) {
return true;
}
return false;
});
Opal.defn(self, '$respond_to_missing?', function(method_name) {
var self = this;
return false;
});
Opal.defn(self, '$require', function(file) {
var self = this;
file = $scope.get('Opal')['$coerce_to!'](file, $scope.get('String'), "to_str");
return Opal.require(Opal.normalize_loadable_path(file));
});
Opal.defn(self, '$require_relative', function(file) {
var self = this;
$scope.get('Opal')['$try_convert!'](file, $scope.get('String'), "to_str");
file = $scope.get('File').$expand_path($scope.get('File').$join(Opal.current_file, "..", file));
return Opal.require(Opal.normalize_loadable_path(file));
});
Opal.defn(self, '$require_tree', function(path) {
var self = this;
path = $scope.get('File').$expand_path(path);
for (var name in Opal.modules) {
if ((name)['$start_with?'](path)) {
Opal.require(name);
}
}
;
return nil;
});
Opal.defn(self, '$send', def.$__send__);
Opal.defn(self, '$public_send', def.$__send__);
Opal.defn(self, '$singleton_class', function() {
var self = this;
return Opal.get_singleton_class(self);
});
Opal.defn(self, '$sprintf', def.$format);
Opal.defn(self, '$srand', def.$rand);
Opal.defn(self, '$String', function(str) {
var self = this;
return String(str);
});
Opal.defn(self, '$taint', function() {
var self = this;
return self;
});
Opal.defn(self, '$tainted?', function() {
var self = this;
return false;
});
Opal.defn(self, '$tap', TMP_10 = function() {
var self = this, $iter = TMP_10.$$p, block = $iter || nil;
TMP_10.$$p = null;
if (Opal.yield1(block, self) === $breaker) return $breaker.$v;
return self;
});
Opal.defn(self, '$to_proc', function() {
var self = this;
return self;
});
Opal.defn(self, '$to_s', function() {
var self = this;
return "#<" + (self.$class()) + ":0x" + (self.$__id__().$to_s(16)) + ">";
});
Opal.defn(self, '$untaint', def.$taint);
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/nil_class"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$raise']);
(function($base, $super) {
function $NilClass(){};
var self = $NilClass = $klass($base, $super, 'NilClass', $NilClass);
var def = self.$$proto, $scope = self.$$scope;
def['$!'] = function() {
var self = this;
return true;
};
def['$&'] = function(other) {
var self = this;
return false;
};
def['$|'] = function(other) {
var self = this;
return other !== false && other !== nil;
};
def['$^'] = function(other) {
var self = this;
return other !== false && other !== nil;
};
def['$=='] = function(other) {
var self = this;
return other === nil;
};
def.$dup = function() {
var self = this;
return self.$raise($scope.get('TypeError'));
};
def.$inspect = function() {
var self = this;
return "nil";
};
def['$nil?'] = function() {
var self = this;
return true;
};
def.$singleton_class = function() {
var self = this;
return $scope.get('NilClass');
};
def.$to_a = function() {
var self = this;
return [];
};
def.$to_h = function() {
var self = this;
return Opal.hash();
};
def.$to_i = function() {
var self = this;
return 0;
};
Opal.defn(self, '$to_f', def.$to_i);
return (def.$to_s = function() {
var self = this;
return "";
}, nil) && 'to_s';
})(self, null);
return Opal.cdecl($scope, 'NIL', nil);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/boolean"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$undef_method']);
(function($base, $super) {
function $Boolean(){};
var self = $Boolean = $klass($base, $super, 'Boolean', $Boolean);
var def = self.$$proto, $scope = self.$$scope;
def.$$is_boolean = true;
(function(self) {
var $scope = self.$$scope, def = self.$$proto;
return self.$undef_method("new")
})(self.$singleton_class());
def['$!'] = function() {
var self = this;
return self != true;
};
def['$&'] = function(other) {
var self = this;
return (self == true) ? (other !== false && other !== nil) : false;
};
def['$|'] = function(other) {
var self = this;
return (self == true) ? true : (other !== false && other !== nil);
};
def['$^'] = function(other) {
var self = this;
return (self == true) ? (other === false || other === nil) : (other !== false && other !== nil);
};
def['$=='] = function(other) {
var self = this;
return (self == true) === other.valueOf();
};
Opal.defn(self, '$equal?', def['$==']);
Opal.defn(self, '$singleton_class', def.$class);
return (def.$to_s = function() {
var self = this;
return (self == true) ? 'true' : 'false';
}, nil) && 'to_s';
})(self, null);
Opal.cdecl($scope, 'TrueClass', $scope.get('Boolean'));
Opal.cdecl($scope, 'FalseClass', $scope.get('Boolean'));
Opal.cdecl($scope, 'TRUE', true);
return Opal.cdecl($scope, 'FALSE', false);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/error"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module;
Opal.add_stubs(['$attr_reader', '$class']);
(function($base, $super) {
function $Exception(){};
var self = $Exception = $klass($base, $super, 'Exception', $Exception);
var def = self.$$proto, $scope = self.$$scope;
def.message = nil;
self.$attr_reader("message");
Opal.defs(self, '$new', function(message) {
var self = this;
if (message == null) {
message = "Exception"
}
var err = new self.$$alloc(message);
if (Error.captureStackTrace) {
Error.captureStackTrace(err);
}
err.name = self.$$name;
err.$initialize(message);
return err;
});
def.$initialize = function(message) {
var self = this;
return self.message = message;
};
def.$backtrace = function() {
var self = this;
var backtrace = self.stack;
if (typeof(backtrace) === 'string') {
return backtrace.split("\n").slice(0, 15);
}
else if (backtrace) {
return backtrace.slice(0, 15);
}
return [];
};
def.$inspect = function() {
var self = this;
return "#<" + (self.$class()) + ": '" + (self.message) + "'>";
};
return Opal.defn(self, '$to_s', def.$message);
})(self, null);
(function($base, $super) {
function $ScriptError(){};
var self = $ScriptError = $klass($base, $super, 'ScriptError', $ScriptError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Exception'));
(function($base, $super) {
function $SyntaxError(){};
var self = $SyntaxError = $klass($base, $super, 'SyntaxError', $SyntaxError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('ScriptError'));
(function($base, $super) {
function $LoadError(){};
var self = $LoadError = $klass($base, $super, 'LoadError', $LoadError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('ScriptError'));
(function($base, $super) {
function $NotImplementedError(){};
var self = $NotImplementedError = $klass($base, $super, 'NotImplementedError', $NotImplementedError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('ScriptError'));
(function($base, $super) {
function $SystemExit(){};
var self = $SystemExit = $klass($base, $super, 'SystemExit', $SystemExit);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Exception'));
(function($base, $super) {
function $NoMemoryError(){};
var self = $NoMemoryError = $klass($base, $super, 'NoMemoryError', $NoMemoryError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Exception'));
(function($base, $super) {
function $SignalException(){};
var self = $SignalException = $klass($base, $super, 'SignalException', $SignalException);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Exception'));
(function($base, $super) {
function $Interrupt(){};
var self = $Interrupt = $klass($base, $super, 'Interrupt', $Interrupt);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Exception'));
(function($base, $super) {
function $StandardError(){};
var self = $StandardError = $klass($base, $super, 'StandardError', $StandardError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Exception'));
(function($base, $super) {
function $NameError(){};
var self = $NameError = $klass($base, $super, 'NameError', $NameError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $NoMethodError(){};
var self = $NoMethodError = $klass($base, $super, 'NoMethodError', $NoMethodError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('NameError'));
(function($base, $super) {
function $RuntimeError(){};
var self = $RuntimeError = $klass($base, $super, 'RuntimeError', $RuntimeError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $LocalJumpError(){};
var self = $LocalJumpError = $klass($base, $super, 'LocalJumpError', $LocalJumpError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $TypeError(){};
var self = $TypeError = $klass($base, $super, 'TypeError', $TypeError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $ArgumentError(){};
var self = $ArgumentError = $klass($base, $super, 'ArgumentError', $ArgumentError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $IndexError(){};
var self = $IndexError = $klass($base, $super, 'IndexError', $IndexError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $StopIteration(){};
var self = $StopIteration = $klass($base, $super, 'StopIteration', $StopIteration);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('IndexError'));
(function($base, $super) {
function $KeyError(){};
var self = $KeyError = $klass($base, $super, 'KeyError', $KeyError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('IndexError'));
(function($base, $super) {
function $RangeError(){};
var self = $RangeError = $klass($base, $super, 'RangeError', $RangeError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $FloatDomainError(){};
var self = $FloatDomainError = $klass($base, $super, 'FloatDomainError', $FloatDomainError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('RangeError'));
(function($base, $super) {
function $IOError(){};
var self = $IOError = $klass($base, $super, 'IOError', $IOError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
(function($base, $super) {
function $SystemCallError(){};
var self = $SystemCallError = $klass($base, $super, 'SystemCallError', $SystemCallError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('StandardError'));
return (function($base) {
var self = $module($base, 'Errno');
var def = self.$$proto, $scope = self.$$scope;
(function($base, $super) {
function $EINVAL(){};
var self = $EINVAL = $klass($base, $super, 'EINVAL', $EINVAL);
var def = self.$$proto, $scope = self.$$scope, TMP_1;
return (Opal.defs(self, '$new', TMP_1 = function() {
var self = this, $iter = TMP_1.$$p, $yield = $iter || nil;
TMP_1.$$p = null;
return Opal.find_super_dispatcher(self, 'new', TMP_1, null, $EINVAL).apply(self, ["Invalid argument"]);
}), nil) && 'new'
})(self, $scope.get('SystemCallError'))
})(self);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/regexp"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars;
Opal.add_stubs(['$nil?', '$[]', '$respond_to?', '$to_str', '$to_s', '$coerce_to', '$new', '$raise', '$class', '$call']);
return (function($base, $super) {
function $Regexp(){};
var self = $Regexp = $klass($base, $super, 'Regexp', $Regexp);
var def = self.$$proto, $scope = self.$$scope, TMP_1;
def.$$is_regexp = true;
(function(self) {
var $scope = self.$$scope, def = self.$$proto;
self.$$proto.$escape = function(string) {
var self = this;
return string.replace(/([-[\]\/{}()*+?.^$\\| ])/g, '\\$1')
.replace(/[\n]/g, '\\n')
.replace(/[\r]/g, '\\r')
.replace(/[\f]/g, '\\f')
.replace(/[\t]/g, '\\t');
};
self.$$proto.$last_match = function(n) {
var $a, self = this;
if ($gvars["~"] == null) $gvars["~"] = nil;
if (n == null) {
n = nil
}
if ((($a = n['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
return $gvars["~"]
} else {
return $gvars["~"]['$[]'](n)
};
};
self.$$proto.$quote = self.$$proto.$escape;
self.$$proto.$union = function(parts) {
var self = this;
parts = $slice.call(arguments, 0);
return new RegExp(parts.join(''));
};
return (self.$$proto.$new = function(regexp, options) {
var self = this;
return new RegExp(regexp, options);
}, nil) && 'new';
})(self.$singleton_class());
def['$=='] = function(other) {
var self = this;
return other.constructor == RegExp && self.toString() === other.toString();
};
def['$==='] = function(str) {
var self = this;
if (!str.$$is_string && str['$respond_to?']("to_str")) {
str = str.$to_str();
}
if (!str.$$is_string) {
return false;
}
return self.test(str);
;
};
def['$=~'] = function(string) {
var $a, self = this;
if ((($a = string === nil) !== nil && (!$a.$$is_boolean || $a == true))) {
$gvars["~"] = nil;
return nil;};
string = $scope.get('Opal').$coerce_to(string, $scope.get('String'), "to_str").$to_s();
var re = self;
if (re.global) {
// should we clear it afterwards too?
re.lastIndex = 0;
}
else {
// rewrite regular expression to add the global flag to capture pre/post match
re = new RegExp(re.source, 'g' + (re.multiline ? 'm' : '') + (re.ignoreCase ? 'i' : ''));
}
var result = re.exec(string);
if (result) {
$gvars["~"] = $scope.get('MatchData').$new(re, result);
return result.index;
}
else {
$gvars["~"] = nil;
return nil;
}
};
Opal.defn(self, '$eql?', def['$==']);
def.$inspect = function() {
var self = this;
return self.toString();
};
def.$match = TMP_1 = function(string, pos) {
var $a, self = this, $iter = TMP_1.$$p, block = $iter || nil;
TMP_1.$$p = null;
if ((($a = string === nil) !== nil && (!$a.$$is_boolean || $a == true))) {
$gvars["~"] = nil;
return nil;};
if ((($a = string.$$is_string == null) !== nil && (!$a.$$is_boolean || $a == true))) {
if ((($a = string['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('TypeError'), "no implicit conversion of " + (string.$class()) + " into String")
};
string = string.$to_str();};
var re = self;
if (re.global) {
// should we clear it afterwards too?
re.lastIndex = 0;
}
else {
re = new RegExp(re.source, 'g' + (re.multiline ? 'm' : '') + (re.ignoreCase ? 'i' : ''));
}
var result = re.exec(string);
if (result) {
result = $gvars["~"] = $scope.get('MatchData').$new(re, result);
if (block === nil) {
return result;
}
else {
return block.$call(result);
}
}
else {
return $gvars["~"] = nil;
}
};
def.$source = function() {
var self = this;
return self.source;
};
return Opal.defn(self, '$to_s', def.$source);
})(self, null)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/comparable"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module;
Opal.add_stubs(['$===', '$>', '$<', '$equal?', '$<=>', '$normalize', '$raise', '$class']);
return (function($base) {
var self = $module($base, 'Comparable');
var def = self.$$proto, $scope = self.$$scope;
Opal.defs(self, '$normalize', function(what) {
var $a, self = this;
if ((($a = $scope.get('Integer')['$==='](what)) !== nil && (!$a.$$is_boolean || $a == true))) {
return what};
if (what['$>'](0)) {
return 1};
if (what['$<'](0)) {
return -1};
return 0;
});
Opal.defn(self, '$==', function(other) {
var $a, self = this, cmp = nil;
try {
if ((($a = self['$equal?'](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
return $scope.get('Comparable').$normalize(cmp) == 0;
} catch ($err) {if (Opal.rescue($err, [$scope.get('StandardError')])) {
return false
}else { throw $err; }
};
});
Opal.defn(self, '$>', function(other) {
var $a, self = this, cmp = nil;
if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed")
};
return $scope.get('Comparable').$normalize(cmp) > 0;
});
Opal.defn(self, '$>=', function(other) {
var $a, self = this, cmp = nil;
if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed")
};
return $scope.get('Comparable').$normalize(cmp) >= 0;
});
Opal.defn(self, '$<', function(other) {
var $a, self = this, cmp = nil;
if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed")
};
return $scope.get('Comparable').$normalize(cmp) < 0;
});
Opal.defn(self, '$<=', function(other) {
var $a, self = this, cmp = nil;
if ((($a = cmp = (self['$<=>'](other))) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed")
};
return $scope.get('Comparable').$normalize(cmp) <= 0;
});
Opal.defn(self, '$between?', function(min, max) {
var self = this;
if (self['$<'](min)) {
return false};
if (self['$>'](max)) {
return false};
return true;
});
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/enumerable"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module;
Opal.add_stubs(['$raise', '$enum_for', '$flatten', '$map', '$==', '$destructure', '$nil?', '$coerce_to!', '$coerce_to', '$===', '$new', '$<<', '$[]', '$[]=', '$inspect', '$__send__', '$yield', '$enumerator_size', '$respond_to?', '$size', '$private', '$compare', '$<=>', '$dup', '$to_a', '$lambda', '$sort', '$call', '$first', '$zip']);
return (function($base) {
var self = $module($base, 'Enumerable');
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_7, TMP_8, TMP_9, TMP_10, TMP_11, TMP_12, TMP_13, TMP_14, TMP_15, TMP_16, TMP_17, TMP_18, TMP_19, TMP_20, TMP_22, TMP_23, TMP_24, TMP_25, TMP_26, TMP_27, TMP_28, TMP_29, TMP_30, TMP_31, TMP_32, TMP_33, TMP_35, TMP_37, TMP_41, TMP_42;
Opal.defn(self, '$all?', TMP_1 = function() {
var $a, self = this, $iter = TMP_1.$$p, block = $iter || nil;
TMP_1.$$p = null;
var result = true;
if (block !== nil) {
self.$each.$$p = function() {
var value = Opal.yieldX(block, arguments);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) {
result = false;
return $breaker;
}
};
}
else {
self.$each.$$p = function(obj) {
if (arguments.length == 1 && (($a = obj) === nil || ($a.$$is_boolean && $a == false))) {
result = false;
return $breaker;
}
};
}
self.$each();
return result;
});
Opal.defn(self, '$any?', TMP_2 = function() {
var $a, self = this, $iter = TMP_2.$$p, block = $iter || nil;
TMP_2.$$p = null;
var result = false;
if (block !== nil) {
self.$each.$$p = function() {
var value = Opal.yieldX(block, arguments);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result = true;
return $breaker;
}
};
}
else {
self.$each.$$p = function(obj) {
if (arguments.length != 1 || (($a = obj) !== nil && (!$a.$$is_boolean || $a == true))) {
result = true;
return $breaker;
}
}
}
self.$each();
return result;
});
Opal.defn(self, '$chunk', TMP_3 = function(state) {
var self = this, $iter = TMP_3.$$p, block = $iter || nil;
TMP_3.$$p = null;
return self.$raise($scope.get('NotImplementedError'));
});
Opal.defn(self, '$collect', TMP_4 = function() {
var self = this, $iter = TMP_4.$$p, block = $iter || nil;
TMP_4.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("collect")
};
var result = [];
self.$each.$$p = function() {
var value = Opal.yieldX(block, arguments);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
result.push(value);
};
self.$each();
return result;
});
Opal.defn(self, '$collect_concat', TMP_5 = function() {
var $a, $b, TMP_6, self = this, $iter = TMP_5.$$p, block = $iter || nil;
TMP_5.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("collect_concat")
};
return ($a = ($b = self).$map, $a.$$p = (TMP_6 = function(item){var self = TMP_6.$$s || this, $a;
if (item == null) item = nil;
return $a = Opal.yield1(block, item), $a === $breaker ? $a : $a}, TMP_6.$$s = self, TMP_6), $a).call($b).$flatten(1);
});
Opal.defn(self, '$count', TMP_7 = function(object) {
var $a, self = this, $iter = TMP_7.$$p, block = $iter || nil;
TMP_7.$$p = null;
var result = 0;
if (object != null) {
block = function() {
return $scope.get('Opal').$destructure(arguments)['$=='](object);
};
}
else if (block === nil) {
block = function() { return true; };
}
self.$each.$$p = function() {
var value = Opal.yieldX(block, arguments);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result++;
}
}
self.$each();
return result;
});
Opal.defn(self, '$cycle', TMP_8 = function(n) {
var $a, self = this, $iter = TMP_8.$$p, block = $iter || nil;
if (n == null) {
n = nil
}
TMP_8.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("cycle", n)
};
if ((($a = n['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
n = $scope.get('Opal')['$coerce_to!'](n, $scope.get('Integer'), "to_int");
if ((($a = n <= 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil};
};
var result,
all = [];
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
all.push(param);
}
self.$each();
if (result !== undefined) {
return result;
}
if (all.length === 0) {
return nil;
}
if ((($a = n['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
while (true) {
for (var i = 0, length = all.length; i < length; i++) {
var value = Opal.yield1(block, all[i]);
if (value === $breaker) {
return $breaker.$v;
}
}
}
} else {
while (n > 1) {
for (var i = 0, length = all.length; i < length; i++) {
var value = Opal.yield1(block, all[i]);
if (value === $breaker) {
return $breaker.$v;
}
}
n--;
}
};
});
Opal.defn(self, '$detect', TMP_9 = function(ifnone) {
var $a, self = this, $iter = TMP_9.$$p, block = $iter || nil;
TMP_9.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("detect", ifnone)
};
var result = undefined;
self.$each.$$p = function() {
var params = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, params);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result = params;
return $breaker;
}
};
self.$each();
if (result === undefined && ifnone !== undefined) {
if (typeof(ifnone) === 'function') {
result = ifnone();
}
else {
result = ifnone;
}
}
return result === undefined ? nil : result;
});
Opal.defn(self, '$drop', function(number) {
var $a, self = this;
number = $scope.get('Opal').$coerce_to(number, $scope.get('Integer'), "to_int");
if ((($a = number < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "attempt to drop negative size")};
var result = [],
current = 0;
self.$each.$$p = function() {
if (number <= current) {
result.push($scope.get('Opal').$destructure(arguments));
}
current++;
};
self.$each()
return result;
});
Opal.defn(self, '$drop_while', TMP_10 = function() {
var $a, self = this, $iter = TMP_10.$$p, block = $iter || nil;
TMP_10.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("drop_while")
};
var result = [],
dropping = true;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
if (dropping) {
var value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) {
dropping = false;
result.push(param);
}
}
else {
result.push(param);
}
};
self.$each();
return result;
});
Opal.defn(self, '$each_cons', TMP_11 = function(n) {
var self = this, $iter = TMP_11.$$p, block = $iter || nil;
TMP_11.$$p = null;
return self.$raise($scope.get('NotImplementedError'));
});
Opal.defn(self, '$each_entry', TMP_12 = function() {
var self = this, $iter = TMP_12.$$p, block = $iter || nil;
TMP_12.$$p = null;
return self.$raise($scope.get('NotImplementedError'));
});
Opal.defn(self, '$each_slice', TMP_13 = function(n) {
var $a, self = this, $iter = TMP_13.$$p, block = $iter || nil;
TMP_13.$$p = null;
n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int");
if ((($a = n <= 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "invalid slice size")};
if ((block !== nil)) {
} else {
return self.$enum_for("each_slice", n)
};
var result,
slice = []
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
slice.push(param);
if (slice.length === n) {
if (Opal.yield1(block, slice) === $breaker) {
result = $breaker.$v;
return $breaker;
}
slice = [];
}
};
self.$each();
if (result !== undefined) {
return result;
}
// our "last" group, if smaller than n then won't have been yielded
if (slice.length > 0) {
if (Opal.yield1(block, slice) === $breaker) {
return $breaker.$v;
}
}
;
return nil;
});
Opal.defn(self, '$each_with_index', TMP_14 = function(args) {
var $a, self = this, $iter = TMP_14.$$p, block = $iter || nil;
args = $slice.call(arguments, 0);
TMP_14.$$p = null;
if ((block !== nil)) {
} else {
return ($a = self).$enum_for.apply($a, ["each_with_index"].concat(args))
};
var result,
index = 0;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = block(param, index);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
index++;
};
self.$each.apply(self, args);
if (result !== undefined) {
return result;
}
return self;
});
Opal.defn(self, '$each_with_object', TMP_15 = function(object) {
var self = this, $iter = TMP_15.$$p, block = $iter || nil;
TMP_15.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("each_with_object", object)
};
var result;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = block(param, object);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
};
self.$each();
if (result !== undefined) {
return result;
}
return object;
});
Opal.defn(self, '$entries', function(args) {
var self = this;
args = $slice.call(arguments, 0);
var result = [];
self.$each.$$p = function() {
result.push($scope.get('Opal').$destructure(arguments));
};
self.$each.apply(self, args);
return result;
});
Opal.defn(self, '$find', def.$detect);
Opal.defn(self, '$find_all', TMP_16 = function() {
var $a, self = this, $iter = TMP_16.$$p, block = $iter || nil;
TMP_16.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("find_all")
};
var result = [];
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result.push(param);
}
};
self.$each();
return result;
});
Opal.defn(self, '$find_index', TMP_17 = function(object) {
var $a, self = this, $iter = TMP_17.$$p, block = $iter || nil;
TMP_17.$$p = null;
if ((($a = object === undefined && block === nil) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.$enum_for("find_index")};
var result = nil,
index = 0;
if (object != null) {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
if ((param)['$=='](object)) {
result = index;
return $breaker;
}
index += 1;
};
}
else if (block !== nil) {
self.$each.$$p = function() {
var value = Opal.yieldX(block, arguments);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result = index;
return $breaker;
}
index += 1;
};
}
self.$each();
return result;
});
Opal.defn(self, '$first', function(number) {
var $a, self = this, result = nil;
if ((($a = number === undefined) !== nil && (!$a.$$is_boolean || $a == true))) {
result = nil;
self.$each.$$p = function() {
result = $scope.get('Opal').$destructure(arguments);
return $breaker;
};
self.$each();
;
} else {
result = [];
number = $scope.get('Opal').$coerce_to(number, $scope.get('Integer'), "to_int");
if ((($a = number < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "attempt to take negative size")};
if ((($a = number == 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return []};
var current = 0,
number = $scope.get('Opal').$coerce_to(number, $scope.get('Integer'), "to_int");
self.$each.$$p = function() {
result.push($scope.get('Opal').$destructure(arguments));
if (number <= ++current) {
return $breaker;
}
};
self.$each();
;
};
return result;
});
Opal.defn(self, '$flat_map', def.$collect_concat);
Opal.defn(self, '$grep', TMP_18 = function(pattern) {
var $a, self = this, $iter = TMP_18.$$p, block = $iter || nil;
TMP_18.$$p = null;
var result = [];
if (block !== nil) {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = pattern['$==='](param);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
result.push(value);
}
};
}
else {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = pattern['$==='](param);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result.push(param);
}
};
}
self.$each();
return result;
;
});
Opal.defn(self, '$group_by', TMP_19 = function() {
var $a, $b, $c, self = this, $iter = TMP_19.$$p, block = $iter || nil, hash = nil;
TMP_19.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("group_by")
};
hash = $scope.get('Hash').$new();
var result;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
(($a = value, $b = hash, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, []))))['$<<'](param);
}
self.$each();
if (result !== undefined) {
return result;
}
return hash;
});
Opal.defn(self, '$include?', function(obj) {
var self = this;
var result = false;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
if ((param)['$=='](obj)) {
result = true;
return $breaker;
}
}
self.$each();
return result;
});
Opal.defn(self, '$inject', TMP_20 = function(object, sym) {
var self = this, $iter = TMP_20.$$p, block = $iter || nil;
TMP_20.$$p = null;
var result = object;
if (block !== nil && sym === undefined) {
self.$each.$$p = function() {
var value = $scope.get('Opal').$destructure(arguments);
if (result === undefined) {
result = value;
return;
}
value = Opal.yieldX(block, [result, value]);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
result = value;
};
}
else {
if (sym === undefined) {
if (!$scope.get('Symbol')['$==='](object)) {
self.$raise($scope.get('TypeError'), "" + (object.$inspect()) + " is not a Symbol");
}
sym = object;
result = undefined;
}
self.$each.$$p = function() {
var value = $scope.get('Opal').$destructure(arguments);
if (result === undefined) {
result = value;
return;
}
result = (result).$__send__(sym, value);
};
}
self.$each();
return result == undefined ? nil : result;
;
});
Opal.defn(self, '$lazy', function() {
var $a, $b, TMP_21, self = this;
return ($a = ($b = (($scope.get('Enumerator')).$$scope.get('Lazy'))).$new, $a.$$p = (TMP_21 = function(enum$, args){var self = TMP_21.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
return ($a = enum$).$yield.apply($a, [].concat(args))}, TMP_21.$$s = self, TMP_21), $a).call($b, self, self.$enumerator_size());
});
Opal.defn(self, '$enumerator_size', function() {
var $a, self = this;
if ((($a = self['$respond_to?']("size")) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.$size()
} else {
return nil
};
});
self.$private("enumerator_size");
Opal.defn(self, '$map', def.$collect);
Opal.defn(self, '$max', TMP_22 = function() {
var self = this, $iter = TMP_22.$$p, block = $iter || nil;
TMP_22.$$p = null;
var result;
if (block !== nil) {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
if (result === undefined) {
result = param;
return;
}
var value = block(param, result);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if (value === nil) {
self.$raise($scope.get('ArgumentError'), "comparison failed");
}
if (value > 0) {
result = param;
}
};
}
else {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
if (result === undefined) {
result = param;
return;
}
if ($scope.get('Opal').$compare(param, result) > 0) {
result = param;
}
};
}
self.$each();
return result === undefined ? nil : result;
});
Opal.defn(self, '$max_by', TMP_23 = function() {
var self = this, $iter = TMP_23.$$p, block = $iter || nil;
TMP_23.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("max_by")
};
var result,
by;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (result === undefined) {
result = param;
by = value;
return;
}
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((value)['$<=>'](by) > 0) {
result = param
by = value;
}
};
self.$each();
return result === undefined ? nil : result;
});
Opal.defn(self, '$member?', def['$include?']);
Opal.defn(self, '$min', TMP_24 = function() {
var self = this, $iter = TMP_24.$$p, block = $iter || nil;
TMP_24.$$p = null;
var result;
if (block !== nil) {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
if (result === undefined) {
result = param;
return;
}
var value = block(param, result);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if (value === nil) {
self.$raise($scope.get('ArgumentError'), "comparison failed");
}
if (value < 0) {
result = param;
}
};
}
else {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments);
if (result === undefined) {
result = param;
return;
}
if ($scope.get('Opal').$compare(param, result) < 0) {
result = param;
}
};
}
self.$each();
return result === undefined ? nil : result;
});
Opal.defn(self, '$min_by', TMP_25 = function() {
var self = this, $iter = TMP_25.$$p, block = $iter || nil;
TMP_25.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("min_by")
};
var result,
by;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (result === undefined) {
result = param;
by = value;
return;
}
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((value)['$<=>'](by) < 0) {
result = param
by = value;
}
};
self.$each();
return result === undefined ? nil : result;
});
Opal.defn(self, '$minmax', TMP_26 = function() {
var self = this, $iter = TMP_26.$$p, block = $iter || nil;
TMP_26.$$p = null;
return self.$raise($scope.get('NotImplementedError'));
});
Opal.defn(self, '$minmax_by', TMP_27 = function() {
var self = this, $iter = TMP_27.$$p, block = $iter || nil;
TMP_27.$$p = null;
return self.$raise($scope.get('NotImplementedError'));
});
Opal.defn(self, '$none?', TMP_28 = function() {
var $a, self = this, $iter = TMP_28.$$p, block = $iter || nil;
TMP_28.$$p = null;
var result = true;
if (block !== nil) {
self.$each.$$p = function() {
var value = Opal.yieldX(block, arguments);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result = false;
return $breaker;
}
}
}
else {
self.$each.$$p = function() {
var value = $scope.get('Opal').$destructure(arguments);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
result = false;
return $breaker;
}
};
}
self.$each();
return result;
});
Opal.defn(self, '$one?', TMP_29 = function() {
var $a, self = this, $iter = TMP_29.$$p, block = $iter || nil;
TMP_29.$$p = null;
var result = false;
if (block !== nil) {
self.$each.$$p = function() {
var value = Opal.yieldX(block, arguments);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
if (result === true) {
result = false;
return $breaker;
}
result = true;
}
}
}
else {
self.$each.$$p = function() {
var value = $scope.get('Opal').$destructure(arguments);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
if (result === true) {
result = false;
return $breaker;
}
result = true;
}
}
}
self.$each();
return result;
});
Opal.defn(self, '$partition', TMP_30 = function() {
var $a, self = this, $iter = TMP_30.$$p, block = $iter || nil;
TMP_30.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("partition")
};
var truthy = [], falsy = [];
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
truthy.push(param);
}
else {
falsy.push(param);
}
};
self.$each();
return [truthy, falsy];
});
Opal.defn(self, '$reduce', def.$inject);
Opal.defn(self, '$reject', TMP_31 = function() {
var $a, self = this, $iter = TMP_31.$$p, block = $iter || nil;
TMP_31.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("reject")
};
var result = [];
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) {
result.push(param);
}
};
self.$each();
return result;
});
Opal.defn(self, '$reverse_each', TMP_32 = function() {
var self = this, $iter = TMP_32.$$p, block = $iter || nil;
TMP_32.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("reverse_each")
};
var result = [];
self.$each.$$p = function() {
result.push(arguments);
};
self.$each();
for (var i = result.length - 1; i >= 0; i--) {
Opal.yieldX(block, result[i]);
}
return result;
});
Opal.defn(self, '$select', def.$find_all);
Opal.defn(self, '$slice_before', TMP_33 = function(pattern) {
var $a, $b, TMP_34, self = this, $iter = TMP_33.$$p, block = $iter || nil;
TMP_33.$$p = null;
if ((($a = pattern === undefined && block === nil || arguments.length > 1) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 1)")};
return ($a = ($b = $scope.get('Enumerator')).$new, $a.$$p = (TMP_34 = function(e){var self = TMP_34.$$s || this, $a;
if (e == null) e = nil;
var slice = [];
if (block !== nil) {
if (pattern === undefined) {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true)) && slice.length > 0) {
e['$<<'](slice);
slice = [];
}
slice.push(param);
};
}
else {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = block(param, pattern.$dup());
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true)) && slice.length > 0) {
e['$<<'](slice);
slice = [];
}
slice.push(param);
};
}
}
else {
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = pattern['$==='](param);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true)) && slice.length > 0) {
e['$<<'](slice);
slice = [];
}
slice.push(param);
};
}
self.$each();
if (slice.length > 0) {
e['$<<'](slice);
}
;}, TMP_34.$$s = self, TMP_34), $a).call($b);
});
Opal.defn(self, '$sort', TMP_35 = function() {
var $a, $b, TMP_36, self = this, $iter = TMP_35.$$p, block = $iter || nil, ary = nil;
TMP_35.$$p = null;
ary = self.$to_a();
if ((block !== nil)) {
} else {
block = ($a = ($b = self).$lambda, $a.$$p = (TMP_36 = function(a, b){var self = TMP_36.$$s || this;
if (a == null) a = nil;if (b == null) b = nil;
return a['$<=>'](b)}, TMP_36.$$s = self, TMP_36), $a).call($b)
};
return ary.sort(block);
});
Opal.defn(self, '$sort_by', TMP_37 = function() {
var $a, $b, TMP_38, $c, $d, TMP_39, $e, $f, TMP_40, self = this, $iter = TMP_37.$$p, block = $iter || nil;
TMP_37.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("sort_by")
};
return ($a = ($b = ($c = ($d = ($e = ($f = self).$map, $e.$$p = (TMP_40 = function(){var self = TMP_40.$$s || this;
arg = $scope.get('Opal').$destructure(arguments);
return [block.$call(arg), arg];}, TMP_40.$$s = self, TMP_40), $e).call($f)).$sort, $c.$$p = (TMP_39 = function(a, b){var self = TMP_39.$$s || this;
if (a == null) a = nil;if (b == null) b = nil;
return a['$[]'](0)['$<=>'](b['$[]'](0))}, TMP_39.$$s = self, TMP_39), $c).call($d)).$map, $a.$$p = (TMP_38 = function(arg){var self = TMP_38.$$s || this;
if (arg == null) arg = nil;
return arg[1];}, TMP_38.$$s = self, TMP_38), $a).call($b);
});
Opal.defn(self, '$take', function(num) {
var self = this;
return self.$first(num);
});
Opal.defn(self, '$take_while', TMP_41 = function() {
var $a, self = this, $iter = TMP_41.$$p, block = $iter || nil;
TMP_41.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("take_while")
};
var result = [];
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = Opal.yield1(block, param);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) {
return $breaker;
}
result.push(param);
};
self.$each();
return result;
});
Opal.defn(self, '$to_a', def.$entries);
Opal.defn(self, '$zip', TMP_42 = function(others) {
var $a, self = this, $iter = TMP_42.$$p, block = $iter || nil;
others = $slice.call(arguments, 0);
TMP_42.$$p = null;
return ($a = self.$to_a()).$zip.apply($a, [].concat(others));
});
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/enumerator"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$require', '$include', '$allocate', '$new', '$to_proc', '$coerce_to', '$nil?', '$empty?', '$+', '$class', '$__send__', '$===', '$call', '$enum_for', '$destructure', '$inspect', '$[]', '$raise', '$yield', '$each', '$enumerator_size', '$respond_to?', '$try_convert', '$<', '$for']);
self.$require("corelib/enumerable");
return (function($base, $super) {
function $Enumerator(){};
var self = $Enumerator = $klass($base, $super, 'Enumerator', $Enumerator);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4;
def.size = def.args = def.object = def.method = nil;
self.$include($scope.get('Enumerable'));
Opal.defs(self, '$for', TMP_1 = function(object, method, args) {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
args = $slice.call(arguments, 2);
if (method == null) {
method = "each"
}
TMP_1.$$p = null;
var obj = self.$allocate();
obj.object = object;
obj.size = block;
obj.method = method;
obj.args = args;
return obj;
;
});
def.$initialize = TMP_2 = function() {
var $a, $b, self = this, $iter = TMP_2.$$p, block = $iter || nil;
TMP_2.$$p = null;
if (block !== false && block !== nil) {
self.object = ($a = ($b = $scope.get('Generator')).$new, $a.$$p = block.$to_proc(), $a).call($b);
self.method = "each";
self.args = [];
self.size = arguments[0] || nil;
if ((($a = self.size) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.size = $scope.get('Opal').$coerce_to(self.size, $scope.get('Integer'), "to_int")
} else {
return nil
};
} else {
self.object = arguments[0];
self.method = arguments[1] || "each";
self.args = $slice.call(arguments, 2);
return self.size = nil;
};
};
def.$each = TMP_3 = function(args) {
var $a, $b, $c, self = this, $iter = TMP_3.$$p, block = $iter || nil;
args = $slice.call(arguments, 0);
TMP_3.$$p = null;
if ((($a = ($b = block['$nil?'](), $b !== false && $b !== nil ?args['$empty?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return self};
args = self.args['$+'](args);
if ((($a = block['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
return ($a = self.$class()).$new.apply($a, [self.object, self.method].concat(args))};
return ($b = ($c = self.object).$__send__, $b.$$p = block.$to_proc(), $b).apply($c, [self.method].concat(args));
};
def.$size = function() {
var $a, self = this;
if ((($a = $scope.get('Proc')['$==='](self.size)) !== nil && (!$a.$$is_boolean || $a == true))) {
return ($a = self.size).$call.apply($a, [].concat(self.args))
} else {
return self.size
};
};
def.$with_index = TMP_4 = function(offset) {
var self = this, $iter = TMP_4.$$p, block = $iter || nil;
if (offset == null) {
offset = 0
}
TMP_4.$$p = null;
if (offset !== false && offset !== nil) {
offset = $scope.get('Opal').$coerce_to(offset, $scope.get('Integer'), "to_int")
} else {
offset = 0
};
if (block !== false && block !== nil) {
} else {
return self.$enum_for("with_index", offset)
};
var result, index = 0;
self.$each.$$p = function() {
var param = $scope.get('Opal').$destructure(arguments),
value = block(param, index);
if (value === $breaker) {
result = $breaker.$v;
return $breaker;
}
index++;
}
self.$each();
if (result !== undefined) {
return result;
}
return nil;
};
Opal.defn(self, '$with_object', def.$each_with_object);
def.$inspect = function() {
var $a, self = this, result = nil;
result = "#<" + (self.$class()) + ": " + (self.object.$inspect()) + ":" + (self.method);
if ((($a = self.args['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
result = result['$+']("(" + (self.args.$inspect()['$[]']($scope.get('Range').$new(1, -2))) + ")")
};
return result['$+'](">");
};
(function($base, $super) {
function $Generator(){};
var self = $Generator = $klass($base, $super, 'Generator', $Generator);
var def = self.$$proto, $scope = self.$$scope, TMP_5, TMP_6;
def.block = nil;
self.$include($scope.get('Enumerable'));
def.$initialize = TMP_5 = function() {
var self = this, $iter = TMP_5.$$p, block = $iter || nil;
TMP_5.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('LocalJumpError'), "no block given")
};
return self.block = block;
};
return (def.$each = TMP_6 = function(args) {
var $a, $b, self = this, $iter = TMP_6.$$p, block = $iter || nil, yielder = nil;
args = $slice.call(arguments, 0);
TMP_6.$$p = null;
yielder = ($a = ($b = $scope.get('Yielder')).$new, $a.$$p = block.$to_proc(), $a).call($b);
try {
args.unshift(yielder);
if (Opal.yieldX(self.block, args) === $breaker) {
return $breaker.$v;
}
}
catch (e) {
if (e === $breaker) {
return $breaker.$v;
}
else {
throw e;
}
}
;
return self;
}, nil) && 'each';
})(self, null);
(function($base, $super) {
function $Yielder(){};
var self = $Yielder = $klass($base, $super, 'Yielder', $Yielder);
var def = self.$$proto, $scope = self.$$scope, TMP_7;
def.block = nil;
def.$initialize = TMP_7 = function() {
var self = this, $iter = TMP_7.$$p, block = $iter || nil;
TMP_7.$$p = null;
return self.block = block;
};
def.$yield = function(values) {
var self = this;
values = $slice.call(arguments, 0);
var value = Opal.yieldX(self.block, values);
if (value === $breaker) {
throw $breaker;
}
return value;
;
};
return (def['$<<'] = function(values) {
var $a, self = this;
values = $slice.call(arguments, 0);
($a = self).$yield.apply($a, [].concat(values));
return self;
}, nil) && '<<';
})(self, null);
return (function($base, $super) {
function $Lazy(){};
var self = $Lazy = $klass($base, $super, 'Lazy', $Lazy);
var def = self.$$proto, $scope = self.$$scope, TMP_8, TMP_11, TMP_13, TMP_18, TMP_20, TMP_21, TMP_23, TMP_26, TMP_29;
def.enumerator = nil;
(function($base, $super) {
function $StopLazyError(){};
var self = $StopLazyError = $klass($base, $super, 'StopLazyError', $StopLazyError);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Exception'));
def.$initialize = TMP_8 = function(object, size) {
var TMP_9, self = this, $iter = TMP_8.$$p, block = $iter || nil;
if (size == null) {
size = nil
}
TMP_8.$$p = null;
if ((block !== nil)) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to call lazy new without a block")
};
self.enumerator = object;
return Opal.find_super_dispatcher(self, 'initialize', TMP_8, (TMP_9 = function(yielder, each_args){var self = TMP_9.$$s || this, $a, $b, TMP_10;
if (yielder == null) yielder = nil;each_args = $slice.call(arguments, 1);
try {
return ($a = ($b = object).$each, $a.$$p = (TMP_10 = function(args){var self = TMP_10.$$s || this;
args = $slice.call(arguments, 0);
args.unshift(yielder);
if (Opal.yieldX(block, args) === $breaker) {
return $breaker;
}
;}, TMP_10.$$s = self, TMP_10), $a).apply($b, [].concat(each_args))
} catch ($err) {if (Opal.rescue($err, [$scope.get('Exception')])) {
return nil
}else { throw $err; }
}}, TMP_9.$$s = self, TMP_9)).apply(self, [size]);
};
Opal.defn(self, '$force', def.$to_a);
def.$lazy = function() {
var self = this;
return self;
};
def.$collect = TMP_11 = function() {
var $a, $b, TMP_12, self = this, $iter = TMP_11.$$p, block = $iter || nil;
TMP_11.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to call lazy map without a block")
};
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_12 = function(enum$, args){var self = TMP_12.$$s || this;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
var value = Opal.yieldX(block, args);
if (value === $breaker) {
return $breaker;
}
enum$.$yield(value);
}, TMP_12.$$s = self, TMP_12), $a).call($b, self, self.$enumerator_size());
};
def.$collect_concat = TMP_13 = function() {
var $a, $b, TMP_14, self = this, $iter = TMP_13.$$p, block = $iter || nil;
TMP_13.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to call lazy map without a block")
};
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_14 = function(enum$, args){var self = TMP_14.$$s || this, $a, $b, TMP_15, $c, TMP_16;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
var value = Opal.yieldX(block, args);
if (value === $breaker) {
return $breaker;
}
if ((value)['$respond_to?']("force") && (value)['$respond_to?']("each")) {
($a = ($b = (value)).$each, $a.$$p = (TMP_15 = function(v){var self = TMP_15.$$s || this;
if (v == null) v = nil;
return enum$.$yield(v)}, TMP_15.$$s = self, TMP_15), $a).call($b)
}
else {
var array = $scope.get('Opal').$try_convert(value, $scope.get('Array'), "to_ary");
if (array === nil) {
enum$.$yield(value);
}
else {
($a = ($c = (value)).$each, $a.$$p = (TMP_16 = function(v){var self = TMP_16.$$s || this;
if (v == null) v = nil;
return enum$.$yield(v)}, TMP_16.$$s = self, TMP_16), $a).call($c);
}
}
;}, TMP_14.$$s = self, TMP_14), $a).call($b, self, nil);
};
def.$drop = function(n) {
var $a, $b, TMP_17, self = this, current_size = nil, set_size = nil, dropped = nil;
n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int");
if (n['$<'](0)) {
self.$raise($scope.get('ArgumentError'), "attempt to drop negative size")};
current_size = self.$enumerator_size();
set_size = (function() {if ((($a = $scope.get('Integer')['$==='](current_size)) !== nil && (!$a.$$is_boolean || $a == true))) {
if (n['$<'](current_size)) {
return n
} else {
return current_size
}
} else {
return current_size
}; return nil; })();
dropped = 0;
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_17 = function(enum$, args){var self = TMP_17.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
if (dropped['$<'](n)) {
return dropped = dropped['$+'](1)
} else {
return ($a = enum$).$yield.apply($a, [].concat(args))
}}, TMP_17.$$s = self, TMP_17), $a).call($b, self, set_size);
};
def.$drop_while = TMP_18 = function() {
var $a, $b, TMP_19, self = this, $iter = TMP_18.$$p, block = $iter || nil, succeeding = nil;
TMP_18.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to call lazy drop_while without a block")
};
succeeding = true;
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_19 = function(enum$, args){var self = TMP_19.$$s || this, $a, $b;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
if (succeeding !== false && succeeding !== nil) {
var value = Opal.yieldX(block, args);
if (value === $breaker) {
return $breaker;
}
if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) {
succeeding = false;
($a = enum$).$yield.apply($a, [].concat(args));
}
} else {
return ($b = enum$).$yield.apply($b, [].concat(args))
}}, TMP_19.$$s = self, TMP_19), $a).call($b, self, nil);
};
def.$enum_for = TMP_20 = function(method, args) {
var $a, $b, self = this, $iter = TMP_20.$$p, block = $iter || nil;
args = $slice.call(arguments, 1);
if (method == null) {
method = "each"
}
TMP_20.$$p = null;
return ($a = ($b = self.$class()).$for, $a.$$p = block.$to_proc(), $a).apply($b, [self, method].concat(args));
};
def.$find_all = TMP_21 = function() {
var $a, $b, TMP_22, self = this, $iter = TMP_21.$$p, block = $iter || nil;
TMP_21.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to call lazy select without a block")
};
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_22 = function(enum$, args){var self = TMP_22.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
var value = Opal.yieldX(block, args);
if (value === $breaker) {
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
($a = enum$).$yield.apply($a, [].concat(args));
}
;}, TMP_22.$$s = self, TMP_22), $a).call($b, self, nil);
};
Opal.defn(self, '$flat_map', def.$collect_concat);
def.$grep = TMP_23 = function(pattern) {
var $a, $b, TMP_24, $c, TMP_25, self = this, $iter = TMP_23.$$p, block = $iter || nil;
TMP_23.$$p = null;
if (block !== false && block !== nil) {
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_24 = function(enum$, args){var self = TMP_24.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
var param = $scope.get('Opal').$destructure(args),
value = pattern['$==='](param);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
value = Opal.yield1(block, param);
if (value === $breaker) {
return $breaker;
}
enum$.$yield(Opal.yield1(block, param));
}
;}, TMP_24.$$s = self, TMP_24), $a).call($b, self, nil)
} else {
return ($a = ($c = $scope.get('Lazy')).$new, $a.$$p = (TMP_25 = function(enum$, args){var self = TMP_25.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
var param = $scope.get('Opal').$destructure(args),
value = pattern['$==='](param);
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
enum$.$yield(param);
}
;}, TMP_25.$$s = self, TMP_25), $a).call($c, self, nil)
};
};
Opal.defn(self, '$map', def.$collect);
Opal.defn(self, '$select', def.$find_all);
def.$reject = TMP_26 = function() {
var $a, $b, TMP_27, self = this, $iter = TMP_26.$$p, block = $iter || nil;
TMP_26.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to call lazy reject without a block")
};
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_27 = function(enum$, args){var self = TMP_27.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
var value = Opal.yieldX(block, args);
if (value === $breaker) {
return $breaker;
}
if ((($a = value) === nil || ($a.$$is_boolean && $a == false))) {
($a = enum$).$yield.apply($a, [].concat(args));
}
;}, TMP_27.$$s = self, TMP_27), $a).call($b, self, nil);
};
def.$take = function(n) {
var $a, $b, TMP_28, self = this, current_size = nil, set_size = nil, taken = nil;
n = $scope.get('Opal').$coerce_to(n, $scope.get('Integer'), "to_int");
if (n['$<'](0)) {
self.$raise($scope.get('ArgumentError'), "attempt to take negative size")};
current_size = self.$enumerator_size();
set_size = (function() {if ((($a = $scope.get('Integer')['$==='](current_size)) !== nil && (!$a.$$is_boolean || $a == true))) {
if (n['$<'](current_size)) {
return n
} else {
return current_size
}
} else {
return current_size
}; return nil; })();
taken = 0;
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_28 = function(enum$, args){var self = TMP_28.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
if (taken['$<'](n)) {
($a = enum$).$yield.apply($a, [].concat(args));
return taken = taken['$+'](1);
} else {
return self.$raise($scope.get('StopLazyError'))
}}, TMP_28.$$s = self, TMP_28), $a).call($b, self, set_size);
};
def.$take_while = TMP_29 = function() {
var $a, $b, TMP_30, self = this, $iter = TMP_29.$$p, block = $iter || nil;
TMP_29.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to call lazy take_while without a block")
};
return ($a = ($b = $scope.get('Lazy')).$new, $a.$$p = (TMP_30 = function(enum$, args){var self = TMP_30.$$s || this, $a;
if (enum$ == null) enum$ = nil;args = $slice.call(arguments, 1);
var value = Opal.yieldX(block, args);
if (value === $breaker) {
return $breaker;
}
if ((($a = value) !== nil && (!$a.$$is_boolean || $a == true))) {
($a = enum$).$yield.apply($a, [].concat(args));
}
else {
self.$raise($scope.get('StopLazyError'));
}
;}, TMP_30.$$s = self, TMP_30), $a).call($b, self, nil);
};
Opal.defn(self, '$to_enum', def.$enum_for);
return (def.$inspect = function() {
var self = this;
return "#<" + (self.$class()) + ": " + (self.enumerator.$inspect()) + ">";
}, nil) && 'inspect';
})(self, self);
})(self, null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/array"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars, $range = Opal.range;
Opal.add_stubs(['$require', '$include', '$new', '$class', '$raise', '$===', '$to_a', '$respond_to?', '$to_ary', '$coerce_to', '$coerce_to?', '$==', '$to_str', '$clone', '$hash', '$<=>', '$inspect', '$empty?', '$enum_for', '$nil?', '$coerce_to!', '$initialize_clone', '$initialize_dup', '$replace', '$eql?', '$length', '$begin', '$end', '$exclude_end?', '$flatten', '$__id__', '$[]', '$to_s', '$join', '$delete_if', '$to_proc', '$each', '$reverse', '$!', '$map', '$rand', '$keep_if', '$shuffle!', '$>', '$<', '$sort', '$times', '$[]=', '$<<', '$at']);
self.$require("corelib/enumerable");
return (function($base, $super) {
function $Array(){};
var self = $Array = $klass($base, $super, 'Array', $Array);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_6, TMP_7, TMP_8, TMP_9, TMP_10, TMP_11, TMP_12, TMP_13, TMP_14, TMP_15, TMP_17, TMP_18, TMP_19, TMP_20, TMP_21, TMP_24;
def.length = nil;
self.$include($scope.get('Enumerable'));
def.$$is_array = true;
Opal.defs(self, '$[]', function(objects) {
var self = this;
objects = $slice.call(arguments, 0);
return objects;
});
def.$initialize = function(args) {
var $a, self = this;
args = $slice.call(arguments, 0);
return ($a = self.$class()).$new.apply($a, [].concat(args));
};
Opal.defs(self, '$new', TMP_1 = function(size, obj) {
var $a, self = this, $iter = TMP_1.$$p, block = $iter || nil;
if (size == null) {
size = nil
}
if (obj == null) {
obj = nil
}
TMP_1.$$p = null;
if ((($a = arguments.length > 2) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (arguments.length) + " for 0..2)")};
if ((($a = arguments.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return []};
if ((($a = arguments.length === 1) !== nil && (!$a.$$is_boolean || $a == true))) {
if ((($a = $scope.get('Array')['$==='](size)) !== nil && (!$a.$$is_boolean || $a == true))) {
return size.$to_a()
} else if ((($a = size['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) {
return size.$to_ary()}};
size = $scope.get('Opal').$coerce_to(size, $scope.get('Integer'), "to_int");
if ((($a = size < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "negative array size")};
var result = [];
if (block === nil) {
for (var i = 0; i < size; i++) {
result.push(obj);
}
}
else {
for (var i = 0, value; i < size; i++) {
value = block(i);
if (value === $breaker) {
return $breaker.$v;
}
result[i] = value;
}
}
return result;
});
Opal.defs(self, '$try_convert', function(obj) {
var self = this;
return $scope.get('Opal')['$coerce_to?'](obj, $scope.get('Array'), "to_ary");
});
def['$&'] = function(other) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_a()
} else {
other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a()
};
var result = [],
seen = {};
for (var i = 0, length = self.length; i < length; i++) {
var item = self[i];
if (!seen[item]) {
for (var j = 0, length2 = other.length; j < length2; j++) {
var item2 = other[j];
if (!seen[item2] && (item)['$=='](item2)) {
seen[item] = true;
result.push(item);
}
}
}
}
return result;
};
def['$|'] = function(other) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_a()
} else {
other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a()
};
var result = [],
seen = {};
for (var i = 0, length = self.length; i < length; i++) {
var item = self[i];
if (!seen[item]) {
seen[item] = true;
result.push(item);
}
}
for (var i = 0, length = other.length; i < length; i++) {
var item = other[i];
if (!seen[item]) {
seen[item] = true;
result.push(item);
}
}
return result;
};
def['$*'] = function(other) {
var $a, self = this;
if ((($a = other['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.join(other.$to_str())};
if ((($a = other['$respond_to?']("to_int")) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('TypeError'), "no implicit conversion of " + (other.$class()) + " into Integer")
};
other = $scope.get('Opal').$coerce_to(other, $scope.get('Integer'), "to_int");
if ((($a = other < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "negative argument")};
var result = [];
for (var i = 0; i < other; i++) {
result = result.concat(self);
}
return result;
};
def['$+'] = function(other) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_a()
} else {
other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a()
};
return self.concat(other);
};
def['$-'] = function(other) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_a()
} else {
other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a()
};
if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return []};
if ((($a = other.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.$clone()};
var seen = {},
result = [];
for (var i = 0, length = other.length; i < length; i++) {
seen[other[i]] = true;
}
for (var i = 0, length = self.length; i < length; i++) {
var item = self[i];
if (!seen[item]) {
result.push(item);
}
}
return result;
};
def['$<<'] = function(object) {
var self = this;
self.push(object);
return self;
};
def['$<=>'] = function(other) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_a()
} else if ((($a = other['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_ary().$to_a()
} else {
return nil
};
if (self.$hash() === other.$hash()) {
return 0;
}
if (self.length != other.length) {
return (self.length > other.length) ? 1 : -1;
}
for (var i = 0, length = self.length; i < length; i++) {
var tmp = (self[i])['$<=>'](other[i]);
if (tmp !== 0) {
return tmp;
}
}
return 0;
;
};
def['$=='] = function(other) {
var $a, self = this;
if ((($a = self === other) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
if ((($a = other['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
return other['$=='](self);
};
other = other.$to_a();
if ((($a = self.length === other.length) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
for (var i = 0, length = self.length; i < length; i++) {
var a = self[i],
b = other[i];
if (a.$$is_array && b.$$is_array && (a === self)) {
continue;
}
if (!(a)['$=='](b)) {
return false;
}
}
return true;
};
def['$[]'] = function(index, length) {
var $a, self = this;
if ((($a = $scope.get('Range')['$==='](index)) !== nil && (!$a.$$is_boolean || $a == true))) {
var size = self.length,
exclude = index.exclude,
from = $scope.get('Opal').$coerce_to(index.begin, $scope.get('Integer'), "to_int"),
to = $scope.get('Opal').$coerce_to(index.end, $scope.get('Integer'), "to_int");
if (from < 0) {
from += size;
if (from < 0) {
return nil;
}
}
if (from > size) {
return nil;
}
if (to < 0) {
to += size;
if (to < 0) {
return [];
}
}
if (!exclude) {
to += 1;
}
return self.slice(from, to);
;
} else {
index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int");
var size = self.length;
if (index < 0) {
index += size;
if (index < 0) {
return nil;
}
}
if (length === undefined) {
if (index >= size || index < 0) {
return nil;
}
return self[index];
}
else {
length = $scope.get('Opal').$coerce_to(length, $scope.get('Integer'), "to_int");
if (length < 0 || index > size || index < 0) {
return nil;
}
return self.slice(index, index + length);
}
};
};
def['$[]='] = function(index, value, extra) {
var $a, self = this, data = nil, length = nil;
if ((($a = $scope.get('Range')['$==='](index)) !== nil && (!$a.$$is_boolean || $a == true))) {
if ((($a = $scope.get('Array')['$==='](value)) !== nil && (!$a.$$is_boolean || $a == true))) {
data = value.$to_a()
} else if ((($a = value['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) {
data = value.$to_ary().$to_a()
} else {
data = [value]
};
var size = self.length,
exclude = index.exclude,
from = $scope.get('Opal').$coerce_to(index.begin, $scope.get('Integer'), "to_int"),
to = $scope.get('Opal').$coerce_to(index.end, $scope.get('Integer'), "to_int");
if (from < 0) {
from += size;
if (from < 0) {
self.$raise($scope.get('RangeError'), "" + (index.$inspect()) + " out of range");
}
}
if (to < 0) {
to += size;
}
if (!exclude) {
to += 1;
}
if (from > size) {
for (var i = size; i < from; i++) {
self[i] = nil;
}
}
if (to < 0) {
self.splice.apply(self, [from, 0].concat(data));
}
else {
self.splice.apply(self, [from, to - from].concat(data));
}
return value;
;
} else {
if ((($a = extra === undefined) !== nil && (!$a.$$is_boolean || $a == true))) {
length = 1
} else {
length = value;
value = extra;
if ((($a = $scope.get('Array')['$==='](value)) !== nil && (!$a.$$is_boolean || $a == true))) {
data = value.$to_a()
} else if ((($a = value['$respond_to?']("to_ary")) !== nil && (!$a.$$is_boolean || $a == true))) {
data = value.$to_ary().$to_a()
} else {
data = [value]
};
};
var size = self.length,
index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int"),
length = $scope.get('Opal').$coerce_to(length, $scope.get('Integer'), "to_int"),
old;
if (index < 0) {
old = index;
index += size;
if (index < 0) {
self.$raise($scope.get('IndexError'), "index " + (old) + " too small for array; minimum " + (-self.length));
}
}
if (length < 0) {
self.$raise($scope.get('IndexError'), "negative length (" + (length) + ")")
}
if (index > size) {
for (var i = size; i < index; i++) {
self[i] = nil;
}
}
if (extra === undefined) {
self[index] = value;
}
else {
self.splice.apply(self, [index, length].concat(data));
}
return value;
;
};
};
def.$assoc = function(object) {
var self = this;
for (var i = 0, length = self.length, item; i < length; i++) {
if (item = self[i], item.length && (item[0])['$=='](object)) {
return item;
}
}
return nil;
};
def.$at = function(index) {
var self = this;
index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int");
if (index < 0) {
index += self.length;
}
if (index < 0 || index >= self.length) {
return nil;
}
return self[index];
};
def.$cycle = TMP_2 = function(n) {
var $a, $b, self = this, $iter = TMP_2.$$p, block = $iter || nil;
if (n == null) {
n = nil
}
TMP_2.$$p = null;
if ((($a = ((($b = self['$empty?']()) !== false && $b !== nil) ? $b : n['$=='](0))) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil};
if (block !== false && block !== nil) {
} else {
return self.$enum_for("cycle", n)
};
if ((($a = n['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
while (true) {
for (var i = 0, length = self.length; i < length; i++) {
var value = Opal.yield1(block, self[i]);
if (value === $breaker) {
return $breaker.$v;
}
}
}
} else {
n = $scope.get('Opal')['$coerce_to!'](n, $scope.get('Integer'), "to_int");
if (n <= 0) {
return self;
}
while (n > 0) {
for (var i = 0, length = self.length; i < length; i++) {
var value = Opal.yield1(block, self[i]);
if (value === $breaker) {
return $breaker.$v;
}
}
n--;
}
};
return self;
};
def.$clear = function() {
var self = this;
self.splice(0, self.length);
return self;
};
def.$clone = function() {
var self = this, copy = nil;
copy = [];
copy.$initialize_clone(self);
return copy;
};
def.$dup = function() {
var self = this, copy = nil;
copy = [];
copy.$initialize_dup(self);
return copy;
};
def.$initialize_copy = function(other) {
var self = this;
return self.$replace(other);
};
def.$collect = TMP_3 = function() {
var self = this, $iter = TMP_3.$$p, block = $iter || nil;
TMP_3.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("collect")
};
var result = [];
for (var i = 0, length = self.length; i < length; i++) {
var value = Opal.yield1(block, self[i]);
if (value === $breaker) {
return $breaker.$v;
}
result.push(value);
}
return result;
};
def['$collect!'] = TMP_4 = function() {
var self = this, $iter = TMP_4.$$p, block = $iter || nil;
TMP_4.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("collect!")
};
for (var i = 0, length = self.length; i < length; i++) {
var value = Opal.yield1(block, self[i]);
if (value === $breaker) {
return $breaker.$v;
}
self[i] = value;
}
return self;
};
def.$compact = function() {
var self = this;
var result = [];
for (var i = 0, length = self.length, item; i < length; i++) {
if ((item = self[i]) !== nil) {
result.push(item);
}
}
return result;
};
def['$compact!'] = function() {
var self = this;
var original = self.length;
for (var i = 0, length = self.length; i < length; i++) {
if (self[i] === nil) {
self.splice(i, 1);
length--;
i--;
}
}
return self.length === original ? nil : self;
};
def.$concat = function(other) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_a()
} else {
other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a()
};
for (var i = 0, length = other.length; i < length; i++) {
self.push(other[i]);
}
return self;
};
def.$delete = function(object) {
var self = this;
var original = self.length;
for (var i = 0, length = original; i < length; i++) {
if ((self[i])['$=='](object)) {
self.splice(i, 1);
length--;
i--;
}
}
return self.length === original ? nil : object;
};
def.$delete_at = function(index) {
var self = this;
index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int");
if (index < 0) {
index += self.length;
}
if (index < 0 || index >= self.length) {
return nil;
}
var result = self[index];
self.splice(index, 1);
return result;
;
};
def.$delete_if = TMP_5 = function() {
var self = this, $iter = TMP_5.$$p, block = $iter || nil;
TMP_5.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("delete_if")
};
for (var i = 0, length = self.length, value; i < length; i++) {
if ((value = block(self[i])) === $breaker) {
return $breaker.$v;
}
if (value !== false && value !== nil) {
self.splice(i, 1);
length--;
i--;
}
}
return self;
};
def.$drop = function(number) {
var self = this;
if (number < 0) {
self.$raise($scope.get('ArgumentError'))
}
return self.slice(number);
;
};
Opal.defn(self, '$dup', def.$clone);
def.$each = TMP_6 = function() {
var self = this, $iter = TMP_6.$$p, block = $iter || nil;
TMP_6.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("each")
};
for (var i = 0, length = self.length; i < length; i++) {
var value = Opal.yield1(block, self[i]);
if (value == $breaker) {
return $breaker.$v;
}
}
return self;
};
def.$each_index = TMP_7 = function() {
var self = this, $iter = TMP_7.$$p, block = $iter || nil;
TMP_7.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("each_index")
};
for (var i = 0, length = self.length; i < length; i++) {
var value = Opal.yield1(block, i);
if (value === $breaker) {
return $breaker.$v;
}
}
return self;
};
def['$empty?'] = function() {
var self = this;
return self.length === 0;
};
def['$eql?'] = function(other) {
var $a, self = this;
if ((($a = self === other) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
other = other.$to_a();
if ((($a = self.length === other.length) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
for (var i = 0, length = self.length; i < length; i++) {
var a = self[i],
b = other[i];
if (a.$$is_array && b.$$is_array && (a === self)) {
continue;
}
if (!(a)['$eql?'](b)) {
return false;
}
}
return true;
};
def.$fetch = TMP_8 = function(index, defaults) {
var self = this, $iter = TMP_8.$$p, block = $iter || nil;
TMP_8.$$p = null;
var original = index;
index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int");
if (index < 0) {
index += self.length;
}
if (index >= 0 && index < self.length) {
return self[index];
}
if (block !== nil) {
return block(original);
}
if (defaults != null) {
return defaults;
}
if (self.length === 0) {
self.$raise($scope.get('IndexError'), "index " + (original) + " outside of array bounds: 0...0")
}
else {
self.$raise($scope.get('IndexError'), "index " + (original) + " outside of array bounds: -" + (self.length) + "..." + (self.length));
}
;
};
def.$fill = TMP_9 = function(args) {
var $a, self = this, $iter = TMP_9.$$p, block = $iter || nil, one = nil, two = nil, obj = nil, left = nil, right = nil;
args = $slice.call(arguments, 0);
TMP_9.$$p = null;
if (block !== false && block !== nil) {
if ((($a = args.length > 2) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (args.$length()) + " for 0..2)")};
$a = Opal.to_ary(args), one = ($a[0] == null ? nil : $a[0]), two = ($a[1] == null ? nil : $a[1]);
} else {
if ((($a = args.length == 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "wrong number of arguments (0 for 1..3)")
} else if ((($a = args.length > 3) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "wrong number of arguments (" + (args.$length()) + " for 1..3)")};
$a = Opal.to_ary(args), obj = ($a[0] == null ? nil : $a[0]), one = ($a[1] == null ? nil : $a[1]), two = ($a[2] == null ? nil : $a[2]);
};
if ((($a = $scope.get('Range')['$==='](one)) !== nil && (!$a.$$is_boolean || $a == true))) {
if (two !== false && two !== nil) {
self.$raise($scope.get('TypeError'), "length invalid with range")};
left = $scope.get('Opal').$coerce_to(one.$begin(), $scope.get('Integer'), "to_int");
if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
left += self.length;};
if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('RangeError'), "" + (one.$inspect()) + " out of range")};
right = $scope.get('Opal').$coerce_to(one.$end(), $scope.get('Integer'), "to_int");
if ((($a = right < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
right += self.length;};
if ((($a = one['$exclude_end?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
right += 1;
};
if ((($a = right <= left) !== nil && (!$a.$$is_boolean || $a == true))) {
return self};
} else if (one !== false && one !== nil) {
left = $scope.get('Opal').$coerce_to(one, $scope.get('Integer'), "to_int");
if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
left += self.length;};
if ((($a = left < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
left = 0};
if (two !== false && two !== nil) {
right = $scope.get('Opal').$coerce_to(two, $scope.get('Integer'), "to_int");
if ((($a = right == 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return self};
right += left;
} else {
right = self.length
};
} else {
left = 0;
right = self.length;
};
if ((($a = left > self.length) !== nil && (!$a.$$is_boolean || $a == true))) {
for (var i = self.length; i < right; i++) {
self[i] = nil;
}
;};
if ((($a = right > self.length) !== nil && (!$a.$$is_boolean || $a == true))) {
self.length = right};
if (block !== false && block !== nil) {
for (var length = self.length; left < right; left++) {
var value = block(left);
if (value === $breaker) {
return $breaker.$v;
}
self[left] = value;
}
;
} else {
for (var length = self.length; left < right; left++) {
self[left] = obj;
}
;
};
return self;
};
def.$first = function(count) {
var self = this;
if (count == null) {
return self.length === 0 ? nil : self[0];
}
count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int");
if (count < 0) {
self.$raise($scope.get('ArgumentError'), "negative array size");
}
return self.slice(0, count);
};
def.$flatten = function(level) {
var self = this;
var result = [];
for (var i = 0, length = self.length; i < length; i++) {
var item = self[i];
if ($scope.get('Opal')['$respond_to?'](item, "to_ary")) {
item = (item).$to_ary();
if (level == null) {
result.push.apply(result, (item).$flatten().$to_a());
}
else if (level == 0) {
result.push(item);
}
else {
result.push.apply(result, (item).$flatten(level - 1).$to_a());
}
}
else {
result.push(item);
}
}
return result;
;
};
def['$flatten!'] = function(level) {
var self = this;
var flattened = self.$flatten(level);
if (self.length == flattened.length) {
for (var i = 0, length = self.length; i < length; i++) {
if (self[i] !== flattened[i]) {
break;
}
}
if (i == length) {
return nil;
}
}
self.$replace(flattened);
;
return self;
};
def.$hash = function() {
var self = this;
var hash = ['A'], item, item_hash;
for (var i = 0, length = self.length; i < length; i++) {
item = self[i];
// Guard against recursion
item_hash = self === item ? 'self' : item.$hash();
hash.push(item_hash);
}
return hash.join(',');
};
def['$include?'] = function(member) {
var self = this;
for (var i = 0, length = self.length; i < length; i++) {
if ((self[i])['$=='](member)) {
return true;
}
}
return false;
};
def.$index = TMP_10 = function(object) {
var self = this, $iter = TMP_10.$$p, block = $iter || nil;
TMP_10.$$p = null;
if (object != null) {
for (var i = 0, length = self.length; i < length; i++) {
if ((self[i])['$=='](object)) {
return i;
}
}
}
else if (block !== nil) {
for (var i = 0, length = self.length, value; i < length; i++) {
if ((value = block(self[i])) === $breaker) {
return $breaker.$v;
}
if (value !== false && value !== nil) {
return i;
}
}
}
else {
return self.$enum_for("index");
}
return nil;
};
def.$insert = function(index, objects) {
var self = this;
objects = $slice.call(arguments, 1);
index = $scope.get('Opal').$coerce_to(index, $scope.get('Integer'), "to_int");
if (objects.length > 0) {
if (index < 0) {
index += self.length + 1;
if (index < 0) {
self.$raise($scope.get('IndexError'), "" + (index) + " is out of bounds");
}
}
if (index > self.length) {
for (var i = self.length; i < index; i++) {
self.push(nil);
}
}
self.splice.apply(self, [index, 0].concat(objects));
}
;
return self;
};
def.$inspect = function() {
var self = this;
var result = [],
id = self.$__id__();
for (var i = 0, length = self.length; i < length; i++) {
var item = self['$[]'](i);
if ((item).$__id__() === id) {
result.push('[...]');
}
else {
result.push((item).$inspect());
}
}
return '[' + result.join(', ') + ']';
;
};
def.$join = function(sep) {
var $a, self = this;
if ($gvars[","] == null) $gvars[","] = nil;
if (sep == null) {
sep = nil
}
if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return ""};
if ((($a = sep === nil) !== nil && (!$a.$$is_boolean || $a == true))) {
sep = $gvars[","]};
var result = [];
for (var i = 0, length = self.length; i < length; i++) {
var item = self[i];
if ($scope.get('Opal')['$respond_to?'](item, "to_str")) {
var tmp = (item).$to_str();
if (tmp !== nil) {
result.push((tmp).$to_s());
continue;
}
}
if ($scope.get('Opal')['$respond_to?'](item, "to_ary")) {
var tmp = (item).$to_ary();
if (tmp !== nil) {
result.push((tmp).$join(sep));
continue;
}
}
if ($scope.get('Opal')['$respond_to?'](item, "to_s")) {
var tmp = (item).$to_s();
if (tmp !== nil) {
result.push(tmp);
continue;
}
}
self.$raise($scope.get('NoMethodError'), "" + ($scope.get('Opal').$inspect(item)) + " doesn't respond to #to_str, #to_ary or #to_s");
}
if (sep === nil) {
return result.join('');
}
else {
return result.join($scope.get('Opal')['$coerce_to!'](sep, $scope.get('String'), "to_str").$to_s());
}
;
};
def.$keep_if = TMP_11 = function() {
var self = this, $iter = TMP_11.$$p, block = $iter || nil;
TMP_11.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("keep_if")
};
for (var i = 0, length = self.length, value; i < length; i++) {
if ((value = block(self[i])) === $breaker) {
return $breaker.$v;
}
if (value === false || value === nil) {
self.splice(i, 1);
length--;
i--;
}
}
return self;
};
def.$last = function(count) {
var self = this;
if (count == null) {
return self.length === 0 ? nil : self[self.length - 1];
}
count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int");
if (count < 0) {
self.$raise($scope.get('ArgumentError'), "negative array size");
}
if (count > self.length) {
count = self.length;
}
return self.slice(self.length - count, self.length);
};
def.$length = function() {
var self = this;
return self.length;
};
Opal.defn(self, '$map', def.$collect);
Opal.defn(self, '$map!', def['$collect!']);
def.$pop = function(count) {
var $a, self = this;
if ((($a = count === undefined) !== nil && (!$a.$$is_boolean || $a == true))) {
if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil};
return self.pop();};
count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int");
if ((($a = count < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "negative array size")};
if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return []};
if ((($a = count > self.length) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.splice(0, self.length);
} else {
return self.splice(self.length - count, self.length);
};
};
def.$push = function(objects) {
var self = this;
objects = $slice.call(arguments, 0);
for (var i = 0, length = objects.length; i < length; i++) {
self.push(objects[i]);
}
return self;
};
def.$rassoc = function(object) {
var self = this;
for (var i = 0, length = self.length, item; i < length; i++) {
item = self[i];
if (item.length && item[1] !== undefined) {
if ((item[1])['$=='](object)) {
return item;
}
}
}
return nil;
};
def.$reject = TMP_12 = function() {
var self = this, $iter = TMP_12.$$p, block = $iter || nil;
TMP_12.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("reject")
};
var result = [];
for (var i = 0, length = self.length, value; i < length; i++) {
if ((value = block(self[i])) === $breaker) {
return $breaker.$v;
}
if (value === false || value === nil) {
result.push(self[i]);
}
}
return result;
};
def['$reject!'] = TMP_13 = function() {
var $a, $b, self = this, $iter = TMP_13.$$p, block = $iter || nil, original = nil;
TMP_13.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("reject!")
};
original = self.$length();
($a = ($b = self).$delete_if, $a.$$p = block.$to_proc(), $a).call($b);
if (self.$length()['$=='](original)) {
return nil
} else {
return self
};
};
def.$replace = function(other) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_a()
} else {
other = $scope.get('Opal').$coerce_to(other, $scope.get('Array'), "to_ary").$to_a()
};
self.splice(0, self.length);
self.push.apply(self, other);
return self;
};
def.$reverse = function() {
var self = this;
return self.slice(0).reverse();
};
def['$reverse!'] = function() {
var self = this;
return self.reverse();
};
def.$reverse_each = TMP_14 = function() {
var $a, $b, self = this, $iter = TMP_14.$$p, block = $iter || nil;
TMP_14.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("reverse_each")
};
($a = ($b = self.$reverse()).$each, $a.$$p = block.$to_proc(), $a).call($b);
return self;
};
def.$rindex = TMP_15 = function(object) {
var self = this, $iter = TMP_15.$$p, block = $iter || nil;
TMP_15.$$p = null;
if (object != null) {
for (var i = self.length - 1; i >= 0; i--) {
if ((self[i])['$=='](object)) {
return i;
}
}
}
else if (block !== nil) {
for (var i = self.length - 1, value; i >= 0; i--) {
if ((value = block(self[i])) === $breaker) {
return $breaker.$v;
}
if (value !== false && value !== nil) {
return i;
}
}
}
else if (object == null) {
return self.$enum_for("rindex");
}
return nil;
};
def.$sample = function(n) {
var $a, $b, TMP_16, self = this;
if (n == null) {
n = nil
}
if ((($a = ($b = n['$!'](), $b !== false && $b !== nil ?self['$empty?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil};
if ((($a = (($b = n !== false && n !== nil) ? self['$empty?']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return []};
if (n !== false && n !== nil) {
return ($a = ($b = ($range(1, n, false))).$map, $a.$$p = (TMP_16 = function(){var self = TMP_16.$$s || this;
return self['$[]'](self.$rand(self.$length()))}, TMP_16.$$s = self, TMP_16), $a).call($b)
} else {
return self['$[]'](self.$rand(self.$length()))
};
};
def.$select = TMP_17 = function() {
var self = this, $iter = TMP_17.$$p, block = $iter || nil;
TMP_17.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("select")
};
var result = [];
for (var i = 0, length = self.length, item, value; i < length; i++) {
item = self[i];
if ((value = Opal.yield1(block, item)) === $breaker) {
return $breaker.$v;
}
if (value !== false && value !== nil) {
result.push(item);
}
}
return result;
};
def['$select!'] = TMP_18 = function() {
var $a, $b, self = this, $iter = TMP_18.$$p, block = $iter || nil;
TMP_18.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("select!")
};
var original = self.length;
($a = ($b = self).$keep_if, $a.$$p = block.$to_proc(), $a).call($b);
return self.length === original ? nil : self;
};
def.$shift = function(count) {
var $a, self = this;
if ((($a = count === undefined) !== nil && (!$a.$$is_boolean || $a == true))) {
if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil};
return self.shift();};
count = $scope.get('Opal').$coerce_to(count, $scope.get('Integer'), "to_int");
if ((($a = count < 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "negative array size")};
if ((($a = self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return []};
return self.splice(0, count);
};
Opal.defn(self, '$size', def.$length);
def.$shuffle = function() {
var self = this;
return self.$clone()['$shuffle!']();
};
def['$shuffle!'] = function() {
var self = this;
for (var i = self.length - 1; i > 0; i--) {
var tmp = self[i],
j = Math.floor(Math.random() * (i + 1));
self[i] = self[j];
self[j] = tmp;
}
return self;
};
Opal.defn(self, '$slice', def['$[]']);
def['$slice!'] = function(index, length) {
var self = this;
if (index < 0) {
index += self.length;
}
if (length != null) {
return self.splice(index, length);
}
if (index < 0 || index >= self.length) {
return nil;
}
return self.splice(index, 1)[0];
};
def.$sort = TMP_19 = function() {
var $a, self = this, $iter = TMP_19.$$p, block = $iter || nil;
TMP_19.$$p = null;
if ((($a = self.length > 1) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return self
};
if (!(block !== nil)) {
block = function(a, b) {
return (a)['$<=>'](b);
};
}
try {
return self.slice().sort(function(x, y) {
var ret = block(x, y);
if (ret === $breaker) {
throw $breaker;
}
else if (ret === nil) {
self.$raise($scope.get('ArgumentError'), "comparison of " + ((x).$inspect()) + " with " + ((y).$inspect()) + " failed");
}
return (ret)['$>'](0) ? 1 : ((ret)['$<'](0) ? -1 : 0);
});
}
catch (e) {
if (e === $breaker) {
return $breaker.$v;
}
else {
throw e;
}
}
;
};
def['$sort!'] = TMP_20 = function() {
var $a, $b, self = this, $iter = TMP_20.$$p, block = $iter || nil;
TMP_20.$$p = null;
var result;
if ((block !== nil)) {
result = ($a = ($b = (self.slice())).$sort, $a.$$p = block.$to_proc(), $a).call($b);
}
else {
result = (self.slice()).$sort();
}
self.length = 0;
for(var i = 0, length = result.length; i < length; i++) {
self.push(result[i]);
}
return self;
;
};
def.$take = function(count) {
var self = this;
if (count < 0) {
self.$raise($scope.get('ArgumentError'));
}
return self.slice(0, count);
;
};
def.$take_while = TMP_21 = function() {
var self = this, $iter = TMP_21.$$p, block = $iter || nil;
TMP_21.$$p = null;
var result = [];
for (var i = 0, length = self.length, item, value; i < length; i++) {
item = self[i];
if ((value = block(item)) === $breaker) {
return $breaker.$v;
}
if (value === false || value === nil) {
return result;
}
result.push(item);
}
return result;
};
def.$to_a = function() {
var self = this;
return self;
};
Opal.defn(self, '$to_ary', def.$to_a);
Opal.defn(self, '$to_s', def.$inspect);
def.$transpose = function() {
var $a, $b, TMP_22, self = this, result = nil, max = nil;
if ((($a = self['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
return []};
result = [];
max = nil;
($a = ($b = self).$each, $a.$$p = (TMP_22 = function(row){var self = TMP_22.$$s || this, $a, $b, TMP_23;
if (row == null) row = nil;
if ((($a = $scope.get('Array')['$==='](row)) !== nil && (!$a.$$is_boolean || $a == true))) {
row = row.$to_a()
} else {
row = $scope.get('Opal').$coerce_to(row, $scope.get('Array'), "to_ary").$to_a()
};
((($a = max) !== false && $a !== nil) ? $a : max = row.length);
if ((($a = (row.length)['$=='](max)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('IndexError'), "element size differs (" + (row.length) + " should be " + (max))};
return ($a = ($b = (row.length)).$times, $a.$$p = (TMP_23 = function(i){var self = TMP_23.$$s || this, $a, $b, $c, entry = nil;
if (i == null) i = nil;
entry = (($a = i, $b = result, ((($c = $b['$[]']($a)) !== false && $c !== nil) ? $c : $b['$[]=']($a, []))));
return entry['$<<'](row.$at(i));}, TMP_23.$$s = self, TMP_23), $a).call($b);}, TMP_22.$$s = self, TMP_22), $a).call($b);
return result;
};
def.$uniq = function() {
var self = this;
var result = [],
seen = {};
for (var i = 0, length = self.length, item, hash; i < length; i++) {
item = self[i];
hash = item;
if (!seen[hash]) {
seen[hash] = true;
result.push(item);
}
}
return result;
};
def['$uniq!'] = function() {
var self = this;
var original = self.length,
seen = {};
for (var i = 0, length = original, item, hash; i < length; i++) {
item = self[i];
hash = item;
if (!seen[hash]) {
seen[hash] = true;
}
else {
self.splice(i, 1);
length--;
i--;
}
}
return self.length === original ? nil : self;
};
def.$unshift = function(objects) {
var self = this;
objects = $slice.call(arguments, 0);
for (var i = objects.length - 1; i >= 0; i--) {
self.unshift(objects[i]);
}
return self;
};
return (def.$zip = TMP_24 = function(others) {
var self = this, $iter = TMP_24.$$p, block = $iter || nil;
others = $slice.call(arguments, 0);
TMP_24.$$p = null;
var result = [], size = self.length, part, o;
for (var i = 0; i < size; i++) {
part = [self[i]];
for (var j = 0, jj = others.length; j < jj; j++) {
o = others[j][i];
if (o == null) {
o = nil;
}
part[j + 1] = o;
}
result[i] = part;
}
if (block !== nil) {
for (var i = 0; i < size; i++) {
block(result[i]);
}
return nil;
}
return result;
}, nil) && 'zip';
})(self, null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/array/inheritance"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$new', '$allocate', '$initialize', '$to_proc', '$__send__', '$clone', '$respond_to?', '$==', '$eql?', '$inspect', '$*', '$class', '$slice', '$uniq', '$flatten']);
(function($base, $super) {
function $Array(){};
var self = $Array = $klass($base, $super, 'Array', $Array);
var def = self.$$proto, $scope = self.$$scope;
return (Opal.defs(self, '$inherited', function(klass) {
var self = this, replace = nil;
replace = $scope.get('Class').$new((($scope.get('Array')).$$scope.get('Wrapper')));
klass.$$proto = replace.$$proto;
klass.$$proto.$$class = klass;
klass.$$alloc = replace.$$alloc;
klass.$$parent = (($scope.get('Array')).$$scope.get('Wrapper'));
klass.$allocate = replace.$allocate;
klass.$new = replace.$new;
klass["$[]"] = replace["$[]"];
}), nil) && 'inherited'
})(self, null);
return (function($base, $super) {
function $Wrapper(){};
var self = $Wrapper = $klass($base, $super, 'Wrapper', $Wrapper);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5;
def.literal = nil;
Opal.defs(self, '$allocate', TMP_1 = function(array) {
var self = this, $iter = TMP_1.$$p, $yield = $iter || nil, obj = nil;
if (array == null) {
array = []
}
TMP_1.$$p = null;
obj = Opal.find_super_dispatcher(self, 'allocate', TMP_1, null, $Wrapper).apply(self, []);
obj.literal = array;
return obj;
});
Opal.defs(self, '$new', TMP_2 = function(args) {
var $a, $b, self = this, $iter = TMP_2.$$p, block = $iter || nil, obj = nil;
args = $slice.call(arguments, 0);
TMP_2.$$p = null;
obj = self.$allocate();
($a = ($b = obj).$initialize, $a.$$p = block.$to_proc(), $a).apply($b, [].concat(args));
return obj;
});
Opal.defs(self, '$[]', function(objects) {
var self = this;
objects = $slice.call(arguments, 0);
return self.$allocate(objects);
});
def.$initialize = TMP_3 = function(args) {
var $a, $b, self = this, $iter = TMP_3.$$p, block = $iter || nil;
args = $slice.call(arguments, 0);
TMP_3.$$p = null;
return self.literal = ($a = ($b = $scope.get('Array')).$new, $a.$$p = block.$to_proc(), $a).apply($b, [].concat(args));
};
def.$method_missing = TMP_4 = function(args) {
var $a, $b, self = this, $iter = TMP_4.$$p, block = $iter || nil, result = nil;
args = $slice.call(arguments, 0);
TMP_4.$$p = null;
result = ($a = ($b = self.literal).$__send__, $a.$$p = block.$to_proc(), $a).apply($b, [].concat(args));
if ((($a = result === self.literal) !== nil && (!$a.$$is_boolean || $a == true))) {
return self
} else {
return result
};
};
def.$initialize_copy = function(other) {
var self = this;
return self.literal = (other.literal).$clone();
};
def['$respond_to?'] = TMP_5 = function(name) {var $zuper = $slice.call(arguments, 0);
var $a, self = this, $iter = TMP_5.$$p, $yield = $iter || nil;
TMP_5.$$p = null;
return ((($a = Opal.find_super_dispatcher(self, 'respond_to?', TMP_5, $iter).apply(self, $zuper)) !== false && $a !== nil) ? $a : self.literal['$respond_to?'](name));
};
def['$=='] = function(other) {
var self = this;
return self.literal['$=='](other);
};
def['$eql?'] = function(other) {
var self = this;
return self.literal['$eql?'](other);
};
def.$to_a = function() {
var self = this;
return self.literal;
};
def.$to_ary = function() {
var self = this;
return self;
};
def.$inspect = function() {
var self = this;
return self.literal.$inspect();
};
def['$*'] = function(other) {
var self = this;
var result = self.literal['$*'](other);
if (result.$$is_array) {
return self.$class().$allocate(result)
}
else {
return result;
}
;
};
def['$[]'] = function(index, length) {
var self = this;
var result = self.literal.$slice(index, length);
if (result.$$is_array && (index.$$is_range || length !== undefined)) {
return self.$class().$allocate(result)
}
else {
return result;
}
;
};
Opal.defn(self, '$slice', def['$[]']);
def.$uniq = function() {
var self = this;
return self.$class().$allocate(self.literal.$uniq());
};
return (def.$flatten = function(level) {
var self = this;
return self.$class().$allocate(self.literal.$flatten(level));
}, nil) && 'flatten';
})($scope.get('Array'), null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/hash"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$require', '$include', '$!', '$==', '$call', '$coerce_to!', '$lambda?', '$abs', '$arity', '$raise', '$enum_for', '$flatten', '$eql?', '$===', '$clone', '$merge!', '$to_proc', '$alias_method']);
self.$require("corelib/enumerable");
return (function($base, $super) {
function $Hash(){};
var self = $Hash = $klass($base, $super, 'Hash', $Hash);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_6, TMP_7, TMP_8, TMP_9, TMP_10, TMP_11, TMP_12, TMP_13;
def.proc = def.none = nil;
self.$include($scope.get('Enumerable'));
def.$$is_hash = true;
Opal.defs(self, '$[]', function(objs) {
var self = this;
objs = $slice.call(arguments, 0);
return Opal.hash.apply(null, objs);
});
Opal.defs(self, '$allocate', function() {
var self = this;
var hash = new self.$$alloc;
hash.map = {};
hash.smap = {};
hash.keys = [];
hash.none = nil;
hash.proc = nil;
return hash;
});
def.$initialize = TMP_1 = function(defaults) {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
TMP_1.$$p = null;
self.none = (defaults === undefined ? nil : defaults);
self.proc = block;
return self;
};
def['$=='] = function(other) {
var self = this;
if (self === other) {
return true;
}
if (!other.keys || !other.smap || !other.map) {
return false;
}
if (self.keys.length !== other.keys.length) {
return false;
}
var _map = self.map,
smap = self.smap,
_map2 = other.map,
smap2 = other.smap,
map, map2, key, khash, value, value2;
for (var i = 0, length = self.keys.length; i < length; i++) {
key = self.keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
map2 = smap2;
} else {
khash = key.$hash();
map = _map;
map2 = _map2;
}
value = map[khash];
if (value === undefined) console.log('==', key, self);
value2 = map2[khash];
if (value2 === undefined || ((value)['$=='](value2))['$!']()) {
return false;
}
}
return true;
};
def['$[]'] = function(key) {
var self = this;
var map, khash;
if (key.$$is_string) {
map = self.smap;
khash = key;
} else {
map = self.map;
khash = key.$hash();
}
if (map === undefined) { console.log(self, '[] --> key:', key, khash, map) }
if (Opal.hasOwnProperty.call(map, khash)) {
return map[khash];
}
var proc = self.proc;
if (proc !== nil) {
return (proc).$call(self, key);
}
return self.none;
};
def['$[]='] = function(key, value) {
var self = this;
var map, khash, value;
if (key.$$is_string) {
map = self.smap;
khash = key;
} else {
map = self.map;
khash = key.$hash();
}
if (!Opal.hasOwnProperty.call(map, khash)) {
self.keys.push(key);
}
map[khash] = value;
return value;
};
def.$assoc = function(object) {
var self = this;
var keys = self.keys,
map, key, khash;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if ((key)['$=='](object)) {
if (key.$$is_string) {
map = self.smap;
khash = key;
} else {
map = self.map;
khash = key.$hash();
}
return [key, map[khash]];
}
}
return nil;
};
def.$clear = function() {
var self = this;
self.map = {};
self.smap = {};
self.keys = [];
return self;
};
def.$clone = function() {
var self = this;
var _map = {},
smap = {},
_map2 = self.map,
smap2 = self.smap,
keys = [],
map, map2, key, khash, value;
for (var i = 0, length = self.keys.length; i < length; i++) {
key = self.keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
map2 = smap2;
} else {
khash = key.$hash();
map = _map;
map2 = _map2;
}
value = map2[khash];
keys.push(key);
map[khash] = value;
}
var clone = new self.$$class.$$alloc();
clone.map = _map;
clone.smap = smap;
clone.keys = keys;
clone.none = self.none;
clone.proc = self.proc;
return clone;
};
def.$default = function(val) {
var self = this;
if (val !== undefined && self.proc !== nil) {
return self.proc.$call(self, val);
}
return self.none;
;
};
def['$default='] = function(object) {
var self = this;
self.proc = nil;
return (self.none = object);
};
def.$default_proc = function() {
var self = this;
return self.proc;
};
def['$default_proc='] = function(proc) {
var self = this;
if (proc !== nil) {
proc = $scope.get('Opal')['$coerce_to!'](proc, $scope.get('Proc'), "to_proc");
if (proc['$lambda?']() && proc.$arity().$abs() != 2) {
self.$raise($scope.get('TypeError'), "default_proc takes two arguments");
}
}
self.none = nil;
return (self.proc = proc);
;
};
def.$delete = TMP_2 = function(key) {
var self = this, $iter = TMP_2.$$p, block = $iter || nil;
TMP_2.$$p = null;
var result, map, khash;
if (key.$$is_string) {
map = self.smap;
khash = key;
} else {
map = self.map;
khash = key.$hash();
}
result = map[khash];
if (result != null) {
delete map[khash];
self.keys.$delete(key);
return result;
}
if (block !== nil) {
return block.$call(key);
}
return nil;
};
def.$delete_if = TMP_3 = function() {
var self = this, $iter = TMP_3.$$p, block = $iter || nil;
TMP_3.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("delete_if")
};
var _map = self.map,
smap = self.smap,
keys = self.keys,
map, key, value, obj, khash;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
map = smap;
khash = key;
} else {
map = _map;
khash = key.$hash();
}
obj = map[khash];
value = block(key, obj);
if (value === $breaker) {
return $breaker.$v;
}
if (value !== false && value !== nil) {
keys.splice(i, 1);
delete map[khash];
length--;
i--;
}
}
return self;
};
Opal.defn(self, '$dup', def.$clone);
def.$each = TMP_4 = function() {
var self = this, $iter = TMP_4.$$p, block = $iter || nil;
TMP_4.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("each")
};
var _map = self.map,
smap = self.smap,
keys = self.keys,
map, key, khash, value;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
map = smap;
khash = key;
} else {
map = _map;
khash = key.$hash();
}
value = Opal.yield1(block, [key, map[khash]]);
if (value === $breaker) {
return $breaker.$v;
}
}
return self;
};
def.$each_key = TMP_5 = function() {
var self = this, $iter = TMP_5.$$p, block = $iter || nil;
TMP_5.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("each_key")
};
var keys = self.keys, key;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (block(key) === $breaker) {
return $breaker.$v;
}
}
return self;
};
Opal.defn(self, '$each_pair', def.$each);
def.$each_value = TMP_6 = function() {
var self = this, $iter = TMP_6.$$p, block = $iter || nil;
TMP_6.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("each_value")
};
var _map = self.map,
smap = self.smap,
keys = self.keys;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
map = smap;
khash = key;
} else {
map = _map;
khash = key.$hash();
}
if (block(map[khash]) === $breaker) {
return $breaker.$v;
}
}
return self;
};
def['$empty?'] = function() {
var self = this;
return self.keys.length === 0;
};
Opal.defn(self, '$eql?', def['$==']);
def.$fetch = TMP_7 = function(key, defaults) {
var self = this, $iter = TMP_7.$$p, block = $iter || nil;
TMP_7.$$p = null;
var map, khash, value;
if (key.$$is_string) {
khash = key;
map = self.smap;
} else {
khash = key.$hash();
map = self.map;
}
value = map[khash];
if (value != null) {
return value;
}
if (block !== nil) {
var value;
if ((value = block(key)) === $breaker) {
return $breaker.$v;
}
return value;
}
if (defaults != null) {
return defaults;
}
self.$raise($scope.get('KeyError'), "key not found");
};
def.$flatten = function(level) {
var self = this;
var _map = self.map,
smap = self.smap,
keys = self.keys,
result = [],
map, key, khash, value;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
value = map[khash];
result.push(key);
if (value.$$is_array) {
if (level == null || level === 1) {
result.push(value);
}
else {
result = result.concat((value).$flatten(level - 1));
}
}
else {
result.push(value);
}
}
return result;
};
def['$has_key?'] = function(key) {
var self = this;
var keys = self.keys,
map, khash;
if (key.$$is_string) {
khash = key;
map = self.smap;
} else {
khash = key.$hash();
map = self.map;
}
if (Opal.hasOwnProperty.call(map, khash)) {
for (var i = 0, length = keys.length; i < length; i++) {
if (!(key['$eql?'](keys[i]))['$!']()) {
return true;
}
}
}
return false;
};
def['$has_value?'] = function(value) {
var self = this;
for (var khash in self.map) {
if ((self.map[khash])['$=='](value)) {
return true;
}
}
return false;
;
};
var hash_ids = null;
def.$hash = function() {
var self = this;
var top = (hash_ids === null);
try {
var key, value,
hash = ['Hash'],
keys = self.keys,
id = self.$object_id(),
counter = 0;
if (top) {
hash_ids = {}
}
if (hash_ids.hasOwnProperty(id)) {
return 'self';
}
hash_ids[id] = true;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
value = key.$$is_string ? self.smap[key] : self.map[key.$hash()];
key = key.$hash();
value = (typeof(value) === 'undefined') ? '' : value.$hash();
hash.push([key,value]);
}
return hash.sort().join();
} finally {
if (top) {
hash_ids = null;
}
}
};
Opal.defn(self, '$include?', def['$has_key?']);
def.$index = function(object) {
var self = this;
var _map = self.map,
smap = self.smap,
keys = self.keys,
map, khash, key;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
map = smap;
khash = key;
} else {
map = _map;
khash = key.$hash();
}
if ((map[khash])['$=='](object)) {
return key;
}
}
return nil;
};
def.$indexes = function(keys) {
var self = this;
keys = $slice.call(arguments, 0);
var result = [],
_map = self.map,
smap = self.smap,
map, key, khash, value;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
value = map[khash];
if (value != null) {
result.push(value);
}
else {
result.push(self.none);
}
}
return result;
};
Opal.defn(self, '$indices', def.$indexes);
var inspect_ids = null;
def.$inspect = function() {
var self = this;
var top = (inspect_ids === null);
try {
var key, value,
inspect = [],
keys = self.keys
id = self.$object_id(),
counter = 0;
if (top) {
inspect_ids = {}
}
if (inspect_ids.hasOwnProperty(id)) {
return '{...}';
}
inspect_ids[id] = true;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
value = key.$$is_string ? self.smap[key] : self.map[key.$hash()];
key = key.$inspect();
value = value.$inspect();
inspect.push(key + '=>' + value);
}
return '{' + inspect.join(', ') + '}';
} finally {
if (top) {
inspect_ids = null;
}
}
};
def.$invert = function() {
var self = this;
var result = Opal.hash(),
keys = self.keys,
_map = self.map,
smap = self.smap,
keys2 = result.keys,
_map2 = result.map,
smap2 = result.smap,
map, map2, key, khash, value;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
map = smap;
khash = key;
} else {
map = _map;
khash = key.$hash();
}
value = map[khash];
keys2.push(value);
if (value.$$is_string) {
map2 = smap2;
khash = value;
} else {
map2 = _map2;
khash = value.$hash();
}
map2[khash] = key;
}
return result;
};
def.$keep_if = TMP_8 = function() {
var self = this, $iter = TMP_8.$$p, block = $iter || nil;
TMP_8.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("keep_if")
};
var _map = self.map,
smap = self.smap,
keys = self.keys,
map, key, khash, value, keep;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
value = map[khash];
keep = block(key, value);
if (keep === $breaker) {
return $breaker.$v;
}
if (keep === false || keep === nil) {
keys.splice(i, 1);
delete map[khash];
length--;
i--;
}
}
return self;
};
Opal.defn(self, '$key', def.$index);
Opal.defn(self, '$key?', def['$has_key?']);
def.$keys = function() {
var self = this;
return self.keys.slice(0);
};
def.$length = function() {
var self = this;
return self.keys.length;
};
Opal.defn(self, '$member?', def['$has_key?']);
def.$merge = TMP_9 = function(other) {
var $a, $b, self = this, $iter = TMP_9.$$p, block = $iter || nil, cloned = nil;
TMP_9.$$p = null;
if ((($a = $scope.get('Hash')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
other = $scope.get('Opal')['$coerce_to!'](other, $scope.get('Hash'), "to_hash")
};
cloned = self.$clone();
($a = ($b = cloned)['$merge!'], $a.$$p = block.$to_proc(), $a).call($b, other);
return cloned;
};
def['$merge!'] = TMP_10 = function(other) {
var self = this, $iter = TMP_10.$$p, block = $iter || nil;
TMP_10.$$p = null;
if (! $scope.get('Hash')['$==='](other)) {
other = $scope.get('Opal')['$coerce_to!'](other, $scope.get('Hash'), "to_hash");
}
var keys = self.keys,
_map = self.map,
smap = self.smap,
keys2 = other.keys,
_map2 = other.map,
smap2 = other.smap,
map, map2, key, khash, value, value2;
if (block === nil) {
for (var i = 0, length = keys2.length; i < length; i++) {
key = keys2[i];
if (key.$$is_string) {
khash = key;
map = smap;
map2 = smap2;
} else {
khash = key.$hash();
map = _map;
map2 = _map2;
}
if (map[khash] == null) {
keys.push(key);
}
map[khash] = map2[khash];
}
}
else {
for (var i = 0, length = keys2.length; i < length; i++) {
key = keys2[i];
if (key.$$is_string) {
khash = key;
map = smap;
map2 = smap2;
} else {
khash = key.$hash();
map = _map;
map2 = _map2;
}
value = map[khash];
value2 = map2[khash];
if (value == null) {
keys.push(key);
map[khash] = value2;
}
else {
map[khash] = block(key, value, value2);
}
}
}
return self;
;
};
def.$rassoc = function(object) {
var self = this;
var keys = self.keys,
_map = self.map,
smap = self.smap,
key, khash, value;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i]
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
value = map[khash];
if ((value)['$=='](object)) {
return [key, value];
}
}
return nil;
};
def.$reject = TMP_11 = function() {
var self = this, $iter = TMP_11.$$p, block = $iter || nil;
TMP_11.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("reject")
};
var keys = self.keys,
_map = self.map,
smap = self.smap,
result = Opal.hash(),
_map2 = result.map,
smap2 = result.smap,
keys2 = result.keys,
map, map2, key, khash, object, value;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
map2 = smap2;
} else {
khash = key.$hash();
map = _map;
map2 = _map2;
}
object = map[khash];
if ((value = block(key, object)) === $breaker) {
return $breaker.$v;
}
if (value === false || value === nil) {
keys2.push(key);
map2[khash] = object;
}
}
return result;
};
def.$replace = function(other) {
var self = this;
var keys = self.keys = [],
_map = self.map = {},
smap = self.smap = {},
_map2 = other.map,
smap2 = other.smap,
key, khash, map, map2;
for (var i = 0, length = other.keys.length; i < length; i++) {
key = other.keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
map2 = smap2;
} else {
khash = key.$hash();
map = _map;
map2 = _map2;
}
keys.push(key);
map[khash] = map2[khash];
}
return self;
};
def.$select = TMP_12 = function() {
var self = this, $iter = TMP_12.$$p, block = $iter || nil;
TMP_12.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("select")
};
var keys = self.keys,
_map = self.map,
smap = self.smap,
result = Opal.hash(),
_map2 = result.map,
smap2 = result.smap,
keys2 = result.keys,
map, map2, key, khash, value, object;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
map2 = smap2;
} else {
khash = key.$hash();
map = _map;
map2 = _map2;
}
value = map[khash];
object = block(key, value);
if (object === $breaker) {
return $breaker.$v;
}
if (object !== false && object !== nil) {
keys2.push(key);
map2[khash] = value;
}
}
return result;
};
def['$select!'] = TMP_13 = function() {
var self = this, $iter = TMP_13.$$p, block = $iter || nil;
TMP_13.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("select!")
};
var _map = self.map,
smap = self.smap,
keys = self.keys,
result = nil,
key, khash, value, object;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
value = map[khash];
object = block(key, value);
if (object === $breaker) {
return $breaker.$v;
}
if (object === false || object === nil) {
keys.splice(i, 1);
delete map[khash];
length--;
i--;
result = self
}
}
return result;
};
def.$shift = function() {
var self = this;
var keys = self.keys,
_map = self.map,
smap = self.smap,
map, key, khash, value;
if (keys.length) {
key = keys[0];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
value = map[khash];
delete map[khash];
keys.splice(0, 1);
return [key, value];
}
return nil;
};
Opal.defn(self, '$size', def.$length);
self.$alias_method("store", "[]=");
def.$to_a = function() {
var self = this;
var keys = self.keys,
_map = self.map,
smap = self.smap,
result = [],
map, key;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
result.push([key, map[khash]]);
}
return result;
};
def.$to_h = function() {
var self = this;
if (self.$$class === Opal.Hash) {
return self
}
var hash = new Opal.Hash.$$alloc,
cloned = self.$clone();
hash.map = cloned.map;
hash.smap = cloned.smap;
hash.keys = cloned.keys;
hash.none = cloned.none;
hash.proc = cloned.proc;
return hash;
;
};
def.$to_hash = function() {
var self = this;
return self;
};
Opal.defn(self, '$to_s', def.$inspect);
Opal.defn(self, '$update', def['$merge!']);
Opal.defn(self, '$value?', def['$has_value?']);
Opal.defn(self, '$values_at', def.$indexes);
return (def.$values = function() {
var self = this;
var _map = self.map,
smap = self.smap,
keys = self.keys,
result = [],
map, khash;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (key.$$is_string) {
khash = key;
map = smap;
} else {
khash = key.$hash();
map = _map;
}
result.push(map[khash]);
}
return result;
}, nil) && 'values';
})(self, null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/string"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars;
Opal.add_stubs(['$require', '$include', '$to_str', '$===', '$format', '$coerce_to', '$to_s', '$respond_to?', '$<=>', '$raise', '$=~', '$empty?', '$ljust', '$ceil', '$/', '$+', '$rjust', '$floor', '$to_a', '$each_char', '$to_proc', '$coerce_to!', '$initialize_clone', '$initialize_dup', '$enum_for', '$split', '$chomp', '$escape', '$class', '$to_i', '$!', '$each_line', '$match', '$new', '$try_convert', '$chars', '$&', '$join', '$is_a?', '$[]', '$str', '$value', '$proc', '$shift', '$__send__']);
self.$require("corelib/comparable");
(function($base, $super) {
function $String(){};
var self = $String = $klass($base, $super, 'String', $String);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_6, TMP_7;
def.length = nil;
self.$include($scope.get('Comparable'));
def.$$is_string = true;
Opal.defs(self, '$try_convert', function(what) {
var self = this;
try {
return what.$to_str()
} catch ($err) {if (true) {
return nil
}else { throw $err; }
};
});
Opal.defs(self, '$new', function(str) {
var self = this;
if (str == null) {
str = ""
}
return new String(str);
});
def['$%'] = function(data) {
var $a, self = this;
if ((($a = $scope.get('Array')['$==='](data)) !== nil && (!$a.$$is_boolean || $a == true))) {
return ($a = self).$format.apply($a, [self].concat(data))
} else {
return self.$format(self, data)
};
};
def['$*'] = function(count) {
var self = this;
if (count < 1) {
return '';
}
var result = '',
pattern = self;
while (count > 0) {
if (count & 1) {
result += pattern;
}
count >>= 1;
pattern += pattern;
}
return result;
};
def['$+'] = function(other) {
var self = this;
other = $scope.get('Opal').$coerce_to(other, $scope.get('String'), "to_str");
return self + other.$to_s();
};
def['$<=>'] = function(other) {
var $a, self = this;
if ((($a = other['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) {
other = other.$to_str().$to_s();
return self > other ? 1 : (self < other ? -1 : 0);
} else {
var cmp = other['$<=>'](self);
if (cmp === nil) {
return nil;
}
else {
return cmp > 0 ? -1 : (cmp < 0 ? 1 : 0);
}
;
};
};
def['$<<'] = function(other) {
var self = this;
return self.$raise($scope.get('NotImplementedError'), "#<< not supported. Mutable String methods are not supported in Opal.");
};
def['$=='] = function(other) {
var $a, self = this;
if ((($a = $scope.get('String')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
return self.$to_s() == other.$to_s();
};
Opal.defn(self, '$eql?', def['$==']);
Opal.defn(self, '$===', def['$==']);
def['$=~'] = function(other) {
var self = this;
if (other.$$is_string) {
self.$raise($scope.get('TypeError'), "type mismatch: String given");
}
return other['$=~'](self);
;
};
def['$[]'] = function(index, length) {
var self = this;
var size = self.length;
if (index.$$is_range) {
var exclude = index.exclude,
length = index.end,
index = index.begin;
if (index < 0) {
index += size;
}
if (length < 0) {
length += size;
}
if (!exclude) {
length += 1;
}
if (index > size) {
return nil;
}
length = length - index;
if (length < 0) {
length = 0;
}
return self.substr(index, length);
}
if (index < 0) {
index += self.length;
}
if (length == null) {
if (index >= self.length || index < 0) {
return nil;
}
return self.substr(index, 1);
}
if (index > self.length || index < 0) {
return nil;
}
return self.substr(index, length);
};
def.$capitalize = function() {
var self = this;
return self.charAt(0).toUpperCase() + self.substr(1).toLowerCase();
};
Opal.defn(self, '$capitalize!', def['$<<']);
def.$casecmp = function(other) {
var self = this;
other = $scope.get('Opal').$coerce_to(other, $scope.get('String'), "to_str").$to_s();
return (self.toLowerCase())['$<=>'](other.toLowerCase());
};
def.$center = function(width, padstr) {
var $a, self = this;
if (padstr == null) {
padstr = " "
}
width = $scope.get('Opal').$coerce_to(width, $scope.get('Integer'), "to_int");
padstr = $scope.get('Opal').$coerce_to(padstr, $scope.get('String'), "to_str").$to_s();
if ((($a = padstr['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "zero width padding")};
if ((($a = width <= self.length) !== nil && (!$a.$$is_boolean || $a == true))) {
return self};
var ljustified = self.$ljust((width['$+'](self.length))['$/'](2).$ceil(), padstr),
rjustified = self.$rjust((width['$+'](self.length))['$/'](2).$floor(), padstr);
return rjustified + ljustified.slice(self.length);
;
};
def.$chars = TMP_1 = function() {
var $a, $b, self = this, $iter = TMP_1.$$p, block = $iter || nil;
TMP_1.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$each_char().$to_a()
};
return ($a = ($b = self).$each_char, $a.$$p = block.$to_proc(), $a).call($b);
};
def.$chomp = function(separator) {
var $a, self = this;
if ($gvars["/"] == null) $gvars["/"] = nil;
if (separator == null) {
separator = $gvars["/"]
}
if ((($a = separator === nil || self.length === 0) !== nil && (!$a.$$is_boolean || $a == true))) {
return self};
separator = $scope.get('Opal')['$coerce_to!'](separator, $scope.get('String'), "to_str").$to_s();
if (separator === "\n") {
return self.replace(/\r?\n?$/, '');
}
else if (separator === "") {
return self.replace(/(\r?\n)+$/, '');
}
else if (self.length > separator.length) {
var tail = self.substr(self.length - separator.length, separator.length);
if (tail === separator) {
return self.substr(0, self.length - separator.length);
}
}
return self;
};
Opal.defn(self, '$chomp!', def['$<<']);
def.$chop = function() {
var self = this;
var length = self.length;
if (length <= 1) {
return "";
}
if (self.charAt(length - 1) === "\n" && self.charAt(length - 2) === "\r") {
return self.substr(0, length - 2);
}
else {
return self.substr(0, length - 1);
}
};
Opal.defn(self, '$chop!', def['$<<']);
def.$chr = function() {
var self = this;
return self.charAt(0);
};
def.$clone = function() {
var self = this, copy = nil;
copy = self.slice();
copy.$initialize_clone(self);
return copy;
};
def.$dup = function() {
var self = this, copy = nil;
copy = self.slice();
copy.$initialize_dup(self);
return copy;
};
def.$count = function(str) {
var self = this;
return (self.length - self.replace(new RegExp(str, 'g'), '').length) / str.length;
};
Opal.defn(self, '$dup', def.$clone);
def.$downcase = function() {
var self = this;
return self.toLowerCase();
};
Opal.defn(self, '$downcase!', def['$<<']);
def.$each_char = TMP_2 = function() {
var $a, self = this, $iter = TMP_2.$$p, block = $iter || nil;
TMP_2.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("each_char")
};
for (var i = 0, length = self.length; i < length; i++) {
((($a = Opal.yield1(block, self.charAt(i))) === $breaker) ? $breaker.$v : $a);
}
return self;
};
def.$each_line = TMP_3 = function(separator) {
var $a, self = this, $iter = TMP_3.$$p, $yield = $iter || nil;
if ($gvars["/"] == null) $gvars["/"] = nil;
if (separator == null) {
separator = $gvars["/"]
}
TMP_3.$$p = null;
if (($yield !== nil)) {
} else {
return self.$split(separator)
};
var chomped = self.$chomp(),
trailing = self.length != chomped.length,
splitted = chomped.split(separator);
for (var i = 0, length = splitted.length; i < length; i++) {
if (i < length - 1 || trailing) {
((($a = Opal.yield1($yield, splitted[i] + separator)) === $breaker) ? $breaker.$v : $a);
}
else {
((($a = Opal.yield1($yield, splitted[i])) === $breaker) ? $breaker.$v : $a);
}
}
;
return self;
};
def['$empty?'] = function() {
var self = this;
return self.length === 0;
};
def['$end_with?'] = function(suffixes) {
var self = this;
suffixes = $slice.call(arguments, 0);
for (var i = 0, length = suffixes.length; i < length; i++) {
var suffix = $scope.get('Opal').$coerce_to(suffixes[i], $scope.get('String'), "to_str").$to_s();
if (self.length >= suffix.length &&
self.substr(self.length - suffix.length, suffix.length) == suffix) {
return true;
}
}
return false;
};
Opal.defn(self, '$eql?', def['$==']);
Opal.defn(self, '$equal?', def['$===']);
def.$gsub = TMP_4 = function(pattern, replace) {
var $a, $b, self = this, $iter = TMP_4.$$p, block = $iter || nil;
TMP_4.$$p = null;
if ((($a = ((($b = $scope.get('String')['$==='](pattern)) !== false && $b !== nil) ? $b : pattern['$respond_to?']("to_str"))) !== nil && (!$a.$$is_boolean || $a == true))) {
pattern = (new RegExp("" + $scope.get('Regexp').$escape(pattern.$to_str())))};
if ((($a = $scope.get('Regexp')['$==='](pattern)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('TypeError'), "wrong argument type " + (pattern.$class()) + " (expected Regexp)")
};
var pattern = pattern.toString(),
options = pattern.substr(pattern.lastIndexOf('/') + 1) + 'g',
regexp = pattern.substr(1, pattern.lastIndexOf('/') - 1);
self.$sub.$$p = block;
return self.$sub(new RegExp(regexp, options), replace);
};
Opal.defn(self, '$gsub!', def['$<<']);
def.$hash = function() {
var self = this;
return self.toString();
};
def.$hex = function() {
var self = this;
return self.$to_i(16);
};
def['$include?'] = function(other) {
var $a, self = this;
if (other.$$is_string) {
return self.indexOf(other) !== -1;
}
if ((($a = other['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('TypeError'), "no implicit conversion of " + (other.$class()) + " into String")
};
return self.indexOf(other.$to_str()) !== -1;
};
def.$index = function(what, offset) {
var $a, self = this, result = nil;
if (offset == null) {
offset = nil
}
if ((($a = $scope.get('String')['$==='](what)) !== nil && (!$a.$$is_boolean || $a == true))) {
what = what.$to_s()
} else if ((($a = what['$respond_to?']("to_str")) !== nil && (!$a.$$is_boolean || $a == true))) {
what = what.$to_str().$to_s()
} else if ((($a = $scope.get('Regexp')['$==='](what)['$!']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('TypeError'), "type mismatch: " + (what.$class()) + " given")};
result = -1;
if (offset !== false && offset !== nil) {
offset = $scope.get('Opal').$coerce_to(offset, $scope.get('Integer'), "to_int");
var size = self.length;
if (offset < 0) {
offset = offset + size;
}
if (offset > size) {
return nil;
}
if ((($a = $scope.get('Regexp')['$==='](what)) !== nil && (!$a.$$is_boolean || $a == true))) {
result = ((($a = (what['$=~'](self.substr(offset)))) !== false && $a !== nil) ? $a : -1)
} else {
result = self.substr(offset).indexOf(what)
};
if (result !== -1) {
result += offset;
}
} else if ((($a = $scope.get('Regexp')['$==='](what)) !== nil && (!$a.$$is_boolean || $a == true))) {
result = ((($a = (what['$=~'](self))) !== false && $a !== nil) ? $a : -1)
} else {
result = self.indexOf(what)
};
if ((($a = result === -1) !== nil && (!$a.$$is_boolean || $a == true))) {
return nil
} else {
return result
};
};
def.$inspect = function() {
var self = this;
var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
meta = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
};
escapable.lastIndex = 0;
return escapable.test(self) ? '"' + self.replace(escapable, function(a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + self + '"';
};
def.$intern = function() {
var self = this;
return self;
};
def.$lines = function(separator) {
var self = this;
if ($gvars["/"] == null) $gvars["/"] = nil;
if (separator == null) {
separator = $gvars["/"]
}
return self.$each_line(separator).$to_a();
};
def.$length = function() {
var self = this;
return self.length;
};
def.$ljust = function(width, padstr) {
var $a, self = this;
if (padstr == null) {
padstr = " "
}
width = $scope.get('Opal').$coerce_to(width, $scope.get('Integer'), "to_int");
padstr = $scope.get('Opal').$coerce_to(padstr, $scope.get('String'), "to_str").$to_s();
if ((($a = padstr['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "zero width padding")};
if ((($a = width <= self.length) !== nil && (!$a.$$is_boolean || $a == true))) {
return self};
var index = -1,
result = "";
width -= self.length;
while (++index < width) {
result += padstr;
}
return self + result.slice(0, width);
};
def.$lstrip = function() {
var self = this;
return self.replace(/^\s*/, '');
};
Opal.defn(self, '$lstrip!', def['$<<']);
def.$match = TMP_5 = function(pattern, pos) {
var $a, $b, self = this, $iter = TMP_5.$$p, block = $iter || nil;
TMP_5.$$p = null;
if ((($a = ((($b = $scope.get('String')['$==='](pattern)) !== false && $b !== nil) ? $b : pattern['$respond_to?']("to_str"))) !== nil && (!$a.$$is_boolean || $a == true))) {
pattern = (new RegExp("" + $scope.get('Regexp').$escape(pattern.$to_str())))};
if ((($a = $scope.get('Regexp')['$==='](pattern)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('TypeError'), "wrong argument type " + (pattern.$class()) + " (expected Regexp)")
};
return ($a = ($b = pattern).$match, $a.$$p = block.$to_proc(), $a).call($b, self, pos);
};
def.$next = function() {
var self = this;
if (self.length === 0) {
return "";
}
var initial = self.substr(0, self.length - 1);
var last = String.fromCharCode(self.charCodeAt(self.length - 1) + 1);
return initial + last;
};
Opal.defn(self, '$next!', def['$<<']);
def.$ord = function() {
var self = this;
return self.charCodeAt(0);
};
def.$partition = function(str) {
var self = this;
var result = self.split(str);
var splitter = (result[0].length === self.length ? "" : str);
return [result[0], splitter, result.slice(1).join(str.toString())];
};
def.$reverse = function() {
var self = this;
return self.split('').reverse().join('');
};
Opal.defn(self, '$reverse!', def['$<<']);
def.$rindex = function(search, offset) {
var self = this;
var search_type = (search == null ? Opal.NilClass : search.constructor);
if (search_type != String && search_type != RegExp) {
var msg = "type mismatch: " + search_type + " given";
self.$raise($scope.get('TypeError').$new(msg));
}
if (self.length == 0) {
return search.length == 0 ? 0 : nil;
}
var result = -1;
if (offset != null) {
if (offset < 0) {
offset = self.length + offset;
}
if (search_type == String) {
result = self.lastIndexOf(search, offset);
}
else {
result = self.substr(0, offset + 1).$reverse().search(search);
if (result !== -1) {
result = offset - result;
}
}
}
else {
if (search_type == String) {
result = self.lastIndexOf(search);
}
else {
result = self.$reverse().search(search);
if (result !== -1) {
result = self.length - 1 - result;
}
}
}
return result === -1 ? nil : result;
};
def.$rjust = function(width, padstr) {
var $a, self = this;
if (padstr == null) {
padstr = " "
}
width = $scope.get('Opal').$coerce_to(width, $scope.get('Integer'), "to_int");
padstr = $scope.get('Opal').$coerce_to(padstr, $scope.get('String'), "to_str").$to_s();
if ((($a = padstr['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "zero width padding")};
if ((($a = width <= self.length) !== nil && (!$a.$$is_boolean || $a == true))) {
return self};
var chars = Math.floor(width - self.length),
patterns = Math.floor(chars / padstr.length),
result = Array(patterns + 1).join(padstr),
remaining = chars - result.length;
return result + padstr.slice(0, remaining) + self;
};
def.$rstrip = function() {
var self = this;
return self.replace(/\s*$/, '');
};
def.$scan = TMP_6 = function(pattern) {
var self = this, $iter = TMP_6.$$p, block = $iter || nil;
TMP_6.$$p = null;
if (pattern.global) {
// should we clear it afterwards too?
pattern.lastIndex = 0;
}
else {
// rewrite regular expression to add the global flag to capture pre/post match
pattern = new RegExp(pattern.source, 'g' + (pattern.multiline ? 'm' : '') + (pattern.ignoreCase ? 'i' : ''));
}
var result = [];
var match;
while ((match = pattern.exec(self)) != null) {
var match_data = $scope.get('MatchData').$new(pattern, match);
if (block === nil) {
match.length == 1 ? result.push(match[0]) : result.push(match.slice(1));
}
else {
match.length == 1 ? block(match[0]) : block.apply(self, match.slice(1));
}
}
return (block !== nil ? self : result);
};
Opal.defn(self, '$size', def.$length);
Opal.defn(self, '$slice', def['$[]']);
Opal.defn(self, '$slice!', def['$<<']);
def.$split = function(pattern, limit) {
var self = this, $a;
if ($gvars[";"] == null) $gvars[";"] = nil;
if (pattern == null) {
pattern = ((($a = $gvars[";"]) !== false && $a !== nil) ? $a : " ")
}
if (pattern === nil || pattern === undefined) {
pattern = $gvars[";"];
}
var result = [];
if (limit !== undefined) {
limit = $scope.get('Opal')['$coerce_to!'](limit, $scope.get('Integer'), "to_int");
}
if (self.length === 0) {
return [];
}
if (limit === 1) {
return [self];
}
if (pattern && pattern.$$is_regexp) {
var pattern_str = pattern.toString();
/* Opal and JS's repr of an empty RE. */
var blank_pattern = (pattern_str.substr(0, 3) == '/^/') ||
(pattern_str.substr(0, 6) == '/(?:)/');
/* This is our fast path */
if (limit === undefined || limit === 0) {
result = self.split(blank_pattern ? /(?:)/ : pattern);
}
else {
/* RegExp.exec only has sane behavior with global flag */
if (! pattern.global) {
pattern = eval(pattern_str + 'g');
}
var match_data;
var prev_index = 0;
pattern.lastIndex = 0;
while ((match_data = pattern.exec(self)) !== null) {
var segment = self.slice(prev_index, match_data.index);
result.push(segment);
prev_index = pattern.lastIndex;
if (match_data[0].length === 0) {
if (blank_pattern) {
/* explicitly split on JS's empty RE form.*/
pattern = /(?:)/;
}
result = self.split(pattern);
/* with "unlimited", ruby leaves a trail on blanks. */
if (limit !== undefined && limit < 0 && blank_pattern) {
result.push('');
}
prev_index = undefined;
break;
}
if (limit !== undefined && limit > 1 && result.length + 1 == limit) {
break;
}
}
if (prev_index !== undefined) {
result.push(self.slice(prev_index, self.length));
}
}
}
else {
var splitted = 0, start = 0, lim = 0;
if (pattern === nil || pattern === undefined) {
pattern = ' '
} else {
pattern = $scope.get('Opal').$try_convert(pattern, $scope.get('String'), "to_str").$to_s();
}
var string = (pattern == ' ') ? self.replace(/[\r\n\t\v]\s+/g, ' ')
: self;
var cursor = -1;
while ((cursor = string.indexOf(pattern, start)) > -1 && cursor < string.length) {
if (splitted + 1 === limit) {
break;
}
if (pattern == ' ' && cursor == start) {
start = cursor + 1;
continue;
}
result.push(string.substr(start, pattern.length ? cursor - start : 1));
splitted++;
start = cursor + (pattern.length ? pattern.length : 1);
}
if (string.length > 0 && (limit < 0 || string.length > start)) {
if (string.length == start) {
result.push('');
}
else {
result.push(string.substr(start, string.length));
}
}
}
if (limit === undefined || limit === 0) {
while (result[result.length-1] === '') {
result.length = result.length - 1;
}
}
if (limit > 0) {
var tail = result.slice(limit - 1).join('');
result.splice(limit - 1, result.length - 1, tail);
}
return result;
;
};
def.$squeeze = function(sets) {
var self = this;
sets = $slice.call(arguments, 0);
if (sets.length === 0) {
return self.replace(/(.)\1+/g, '$1');
}
var set = $scope.get('Opal').$coerce_to(sets[0], $scope.get('String'), "to_str").$chars();
for (var i = 1, length = sets.length; i < length; i++) {
set = (set)['$&']($scope.get('Opal').$coerce_to(sets[i], $scope.get('String'), "to_str").$chars());
}
if (set.length === 0) {
return self;
}
return self.replace(new RegExp("([" + $scope.get('Regexp').$escape((set).$join()) + "])\\1+", "g"), "$1");
;
};
Opal.defn(self, '$squeeze!', def['$<<']);
def['$start_with?'] = function(prefixes) {
var self = this;
prefixes = $slice.call(arguments, 0);
for (var i = 0, length = prefixes.length; i < length; i++) {
var prefix = $scope.get('Opal').$coerce_to(prefixes[i], $scope.get('String'), "to_str").$to_s();
if (self.indexOf(prefix) === 0) {
return true;
}
}
return false;
};
def.$strip = function() {
var self = this;
return self.replace(/^\s*/, '').replace(/\s*$/, '');
};
Opal.defn(self, '$strip!', def['$<<']);
// convert Ruby back reference to JavaScript back reference
function convertReplace(replace) {
return replace.replace(
/(^|[^\\])\\(\d)/g, function(a, b, c) { return b + '$' + c }
).replace(
/(^|[^\\])(\\\\)+\\\\(\d)/g, '$1$2\\$3'
).replace(
/(^|[^\\])(?:(\\)\\)+([^\\]|$)/g, '$1$2$3'
);
}
def.$sub = TMP_7 = function(pattern, replace) {
var self = this, $iter = TMP_7.$$p, block = $iter || nil;
TMP_7.$$p = null;
if (typeof(pattern) !== 'string' && !pattern.$$is_regexp) {
pattern = $scope.get('Opal')['$coerce_to!'](pattern, $scope.get('String'), "to_str");
}
if (replace !== undefined) {
if (replace['$is_a?']($scope.get('Hash'))) {
return self.replace(pattern, function(str) {
var value = replace['$[]'](self.$str());
return (value == null) ? nil : self.$value().$to_s();
});
}
else {
if (typeof(replace) !== 'string') {
replace = $scope.get('Opal')['$coerce_to!'](replace, $scope.get('String'), "to_str");
}
replace = convertReplace(replace);
return self.replace(pattern, replace);
}
}
else if (block != null && block !== nil) {
return self.replace(pattern, function() {
// FIXME: this should be a formal MatchData object with all the goodies
var match_data = []
for (var i = 0, len = arguments.length; i < len; i++) {
var arg = arguments[i];
if (arg == undefined) {
match_data.push(nil);
}
else {
match_data.push(arg);
}
}
var str = match_data.pop();
var offset = match_data.pop();
var match_len = match_data.length;
// $1, $2, $3 not being parsed correctly in Ruby code
for (var i = 1; i < match_len; i++) {
Opal.gvars[String(i)] = match_data[i];
}
$gvars["&"] = match_data[0];
$gvars["~"] = match_data;
return block(match_data[0]);
});
}
else {
self.$raise($scope.get('ArgumentError'), "wrong number of arguments (1 for 2)")
}
;
};
Opal.defn(self, '$sub!', def['$<<']);
Opal.defn(self, '$succ', def.$next);
Opal.defn(self, '$succ!', def['$<<']);
def.$sum = function(n) {
var self = this;
if (n == null) {
n = 16
}
var result = 0;
for (var i = 0, length = self.length; i < length; i++) {
result += (self.charCodeAt(i) % ((1 << n) - 1));
}
return result;
};
def.$swapcase = function() {
var self = this;
var str = self.replace(/([a-z]+)|([A-Z]+)/g, function($0,$1,$2) {
return $1 ? $0.toUpperCase() : $0.toLowerCase();
});
if (self.constructor === String) {
return str;
}
return self.$class().$new(str);
};
Opal.defn(self, '$swapcase!', def['$<<']);
def.$to_f = function() {
var self = this;
if (self.charAt(0) === '_') {
return 0;
}
var result = parseFloat(self.replace(/_/g, ''));
if (isNaN(result) || result == Infinity || result == -Infinity) {
return 0;
}
else {
return result;
}
};
def.$to_i = function(base) {
var self = this;
if (base == null) {
base = 10
}
var result = parseInt(self, base);
if (isNaN(result)) {
return 0;
}
return result;
};
def.$to_proc = function() {
var $a, $b, TMP_8, self = this, sym = nil;
sym = self;
return ($a = ($b = self).$proc, $a.$$p = (TMP_8 = function(args){var self = TMP_8.$$s || this, block, $a, $b, obj = nil;
args = $slice.call(arguments, 0);
block = TMP_8.$$p || nil, TMP_8.$$p = null;
if ((($a = args['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "no receiver given")};
obj = args.$shift();
return ($a = ($b = obj).$__send__, $a.$$p = block.$to_proc(), $a).apply($b, [sym].concat(args));}, TMP_8.$$s = self, TMP_8), $a).call($b);
};
def.$to_s = function() {
var self = this;
return self.toString();
};
Opal.defn(self, '$to_str', def.$to_s);
Opal.defn(self, '$to_sym', def.$intern);
def.$tr = function(from, to) {
var self = this;
if (from.length == 0 || from === to) {
return self;
}
var subs = {};
var from_chars = from.split('');
var from_length = from_chars.length;
var to_chars = to.split('');
var to_length = to_chars.length;
var inverse = false;
var global_sub = null;
if (from_chars[0] === '^') {
inverse = true;
from_chars.shift();
global_sub = to_chars[to_length - 1]
from_length -= 1;
}
var from_chars_expanded = [];
var last_from = null;
var in_range = false;
for (var i = 0; i < from_length; i++) {
var ch = from_chars[i];
if (last_from == null) {
last_from = ch;
from_chars_expanded.push(ch);
}
else if (ch === '-') {
if (last_from === '-') {
from_chars_expanded.push('-');
from_chars_expanded.push('-');
}
else if (i == from_length - 1) {
from_chars_expanded.push('-');
}
else {
in_range = true;
}
}
else if (in_range) {
var start = last_from.charCodeAt(0) + 1;
var end = ch.charCodeAt(0);
for (var c = start; c < end; c++) {
from_chars_expanded.push(String.fromCharCode(c));
}
from_chars_expanded.push(ch);
in_range = null;
last_from = null;
}
else {
from_chars_expanded.push(ch);
}
}
from_chars = from_chars_expanded;
from_length = from_chars.length;
if (inverse) {
for (var i = 0; i < from_length; i++) {
subs[from_chars[i]] = true;
}
}
else {
if (to_length > 0) {
var to_chars_expanded = [];
var last_to = null;
var in_range = false;
for (var i = 0; i < to_length; i++) {
var ch = to_chars[i];
if (last_from == null) {
last_from = ch;
to_chars_expanded.push(ch);
}
else if (ch === '-') {
if (last_to === '-') {
to_chars_expanded.push('-');
to_chars_expanded.push('-');
}
else if (i == to_length - 1) {
to_chars_expanded.push('-');
}
else {
in_range = true;
}
}
else if (in_range) {
var start = last_from.charCodeAt(0) + 1;
var end = ch.charCodeAt(0);
for (var c = start; c < end; c++) {
to_chars_expanded.push(String.fromCharCode(c));
}
to_chars_expanded.push(ch);
in_range = null;
last_from = null;
}
else {
to_chars_expanded.push(ch);
}
}
to_chars = to_chars_expanded;
to_length = to_chars.length;
}
var length_diff = from_length - to_length;
if (length_diff > 0) {
var pad_char = (to_length > 0 ? to_chars[to_length - 1] : '');
for (var i = 0; i < length_diff; i++) {
to_chars.push(pad_char);
}
}
for (var i = 0; i < from_length; i++) {
subs[from_chars[i]] = to_chars[i];
}
}
var new_str = ''
for (var i = 0, length = self.length; i < length; i++) {
var ch = self.charAt(i);
var sub = subs[ch];
if (inverse) {
new_str += (sub == null ? global_sub : ch);
}
else {
new_str += (sub != null ? sub : ch);
}
}
return new_str;
};
Opal.defn(self, '$tr!', def['$<<']);
def.$tr_s = function(from, to) {
var self = this;
if (from.length == 0) {
return self;
}
var subs = {};
var from_chars = from.split('');
var from_length = from_chars.length;
var to_chars = to.split('');
var to_length = to_chars.length;
var inverse = false;
var global_sub = null;
if (from_chars[0] === '^') {
inverse = true;
from_chars.shift();
global_sub = to_chars[to_length - 1]
from_length -= 1;
}
var from_chars_expanded = [];
var last_from = null;
var in_range = false;
for (var i = 0; i < from_length; i++) {
var ch = from_chars[i];
if (last_from == null) {
last_from = ch;
from_chars_expanded.push(ch);
}
else if (ch === '-') {
if (last_from === '-') {
from_chars_expanded.push('-');
from_chars_expanded.push('-');
}
else if (i == from_length - 1) {
from_chars_expanded.push('-');
}
else {
in_range = true;
}
}
else if (in_range) {
var start = last_from.charCodeAt(0) + 1;
var end = ch.charCodeAt(0);
for (var c = start; c < end; c++) {
from_chars_expanded.push(String.fromCharCode(c));
}
from_chars_expanded.push(ch);
in_range = null;
last_from = null;
}
else {
from_chars_expanded.push(ch);
}
}
from_chars = from_chars_expanded;
from_length = from_chars.length;
if (inverse) {
for (var i = 0; i < from_length; i++) {
subs[from_chars[i]] = true;
}
}
else {
if (to_length > 0) {
var to_chars_expanded = [];
var last_to = null;
var in_range = false;
for (var i = 0; i < to_length; i++) {
var ch = to_chars[i];
if (last_from == null) {
last_from = ch;
to_chars_expanded.push(ch);
}
else if (ch === '-') {
if (last_to === '-') {
to_chars_expanded.push('-');
to_chars_expanded.push('-');
}
else if (i == to_length - 1) {
to_chars_expanded.push('-');
}
else {
in_range = true;
}
}
else if (in_range) {
var start = last_from.charCodeAt(0) + 1;
var end = ch.charCodeAt(0);
for (var c = start; c < end; c++) {
to_chars_expanded.push(String.fromCharCode(c));
}
to_chars_expanded.push(ch);
in_range = null;
last_from = null;
}
else {
to_chars_expanded.push(ch);
}
}
to_chars = to_chars_expanded;
to_length = to_chars.length;
}
var length_diff = from_length - to_length;
if (length_diff > 0) {
var pad_char = (to_length > 0 ? to_chars[to_length - 1] : '');
for (var i = 0; i < length_diff; i++) {
to_chars.push(pad_char);
}
}
for (var i = 0; i < from_length; i++) {
subs[from_chars[i]] = to_chars[i];
}
}
var new_str = ''
var last_substitute = null
for (var i = 0, length = self.length; i < length; i++) {
var ch = self.charAt(i);
var sub = subs[ch]
if (inverse) {
if (sub == null) {
if (last_substitute == null) {
new_str += global_sub;
last_substitute = true;
}
}
else {
new_str += ch;
last_substitute = null;
}
}
else {
if (sub != null) {
if (last_substitute == null || last_substitute !== sub) {
new_str += sub;
last_substitute = sub;
}
}
else {
new_str += ch;
last_substitute = null;
}
}
}
return new_str;
};
Opal.defn(self, '$tr_s!', def['$<<']);
def.$upcase = function() {
var self = this;
return self.toUpperCase();
};
Opal.defn(self, '$upcase!', def['$<<']);
def.$freeze = function() {
var self = this;
return self;
};
return (def['$frozen?'] = function() {
var self = this;
return true;
}, nil) && 'frozen?';
})(self, null);
return Opal.cdecl($scope, 'Symbol', $scope.get('String'));
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/string/inheritance"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$new', '$allocate', '$initialize', '$to_proc', '$__send__', '$class', '$clone', '$respond_to?', '$==', '$inspect']);
(function($base, $super) {
function $String(){};
var self = $String = $klass($base, $super, 'String', $String);
var def = self.$$proto, $scope = self.$$scope;
return (Opal.defs(self, '$inherited', function(klass) {
var self = this, replace = nil;
replace = $scope.get('Class').$new((($scope.get('String')).$$scope.get('Wrapper')));
klass.$$proto = replace.$$proto;
klass.$$proto.$$class = klass;
klass.$$alloc = replace.$$alloc;
klass.$$parent = (($scope.get('String')).$$scope.get('Wrapper'));
klass.$allocate = replace.$allocate;
klass.$new = replace.$new;
}), nil) && 'inherited'
})(self, null);
return (function($base, $super) {
function $Wrapper(){};
var self = $Wrapper = $klass($base, $super, 'Wrapper', $Wrapper);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4;
def.literal = nil;
Opal.defs(self, '$allocate', TMP_1 = function(string) {
var self = this, $iter = TMP_1.$$p, $yield = $iter || nil, obj = nil;
if (string == null) {
string = ""
}
TMP_1.$$p = null;
obj = Opal.find_super_dispatcher(self, 'allocate', TMP_1, null, $Wrapper).apply(self, []);
obj.literal = string;
return obj;
});
Opal.defs(self, '$new', TMP_2 = function(args) {
var $a, $b, self = this, $iter = TMP_2.$$p, block = $iter || nil, obj = nil;
args = $slice.call(arguments, 0);
TMP_2.$$p = null;
obj = self.$allocate();
($a = ($b = obj).$initialize, $a.$$p = block.$to_proc(), $a).apply($b, [].concat(args));
return obj;
});
Opal.defs(self, '$[]', function(objects) {
var self = this;
objects = $slice.call(arguments, 0);
return self.$allocate(objects);
});
def.$initialize = function(string) {
var self = this;
if (string == null) {
string = ""
}
return self.literal = string;
};
def.$method_missing = TMP_3 = function(args) {
var $a, $b, self = this, $iter = TMP_3.$$p, block = $iter || nil, result = nil;
args = $slice.call(arguments, 0);
TMP_3.$$p = null;
result = ($a = ($b = self.literal).$__send__, $a.$$p = block.$to_proc(), $a).apply($b, [].concat(args));
if ((($a = result.$$is_string != null) !== nil && (!$a.$$is_boolean || $a == true))) {
if ((($a = result == self.literal) !== nil && (!$a.$$is_boolean || $a == true))) {
return self
} else {
return self.$class().$allocate(result)
}
} else {
return result
};
};
def.$initialize_copy = function(other) {
var self = this;
return self.literal = (other.literal).$clone();
};
def['$respond_to?'] = TMP_4 = function(name) {var $zuper = $slice.call(arguments, 0);
var $a, self = this, $iter = TMP_4.$$p, $yield = $iter || nil;
TMP_4.$$p = null;
return ((($a = Opal.find_super_dispatcher(self, 'respond_to?', TMP_4, $iter).apply(self, $zuper)) !== false && $a !== nil) ? $a : self.literal['$respond_to?'](name));
};
def['$=='] = function(other) {
var self = this;
return self.literal['$=='](other);
};
Opal.defn(self, '$eql?', def['$==']);
Opal.defn(self, '$===', def['$==']);
def.$to_s = function() {
var self = this;
return self.literal;
};
def.$to_str = function() {
var self = this;
return self;
};
return (def.$inspect = function() {
var self = this;
return self.literal.$inspect();
}, nil) && 'inspect';
})($scope.get('String'), null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/match_data"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars;
Opal.add_stubs(['$attr_reader', '$[]', '$===', '$!', '$==', '$raise', '$inspect']);
return (function($base, $super) {
function $MatchData(){};
var self = $MatchData = $klass($base, $super, 'MatchData', $MatchData);
var def = self.$$proto, $scope = self.$$scope;
def.string = def.matches = def.begin = nil;
self.$attr_reader("post_match", "pre_match", "regexp", "string");
def.$initialize = function(regexp, match_groups) {
var self = this;
$gvars["~"] = self;
self.regexp = regexp;
self.begin = match_groups.index;
self.string = match_groups.input;
self.pre_match = self.string.substr(0, regexp.lastIndex - match_groups[0].length);
self.post_match = self.string.substr(regexp.lastIndex);
self.matches = [];
for (var i = 0, length = match_groups.length; i < length; i++) {
var group = match_groups[i];
if (group == null) {
self.matches.push(nil);
}
else {
self.matches.push(group);
}
}
};
def['$[]'] = function(args) {
var $a, self = this;
args = $slice.call(arguments, 0);
return ($a = self.matches)['$[]'].apply($a, [].concat(args));
};
def['$=='] = function(other) {
var $a, $b, $c, $d, self = this;
if ((($a = $scope.get('MatchData')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
return ($a = ($b = ($c = ($d = self.string == other.string, $d !== false && $d !== nil ?self.regexp == other.regexp : $d), $c !== false && $c !== nil ?self.pre_match == other.pre_match : $c), $b !== false && $b !== nil ?self.post_match == other.post_match : $b), $a !== false && $a !== nil ?self.begin == other.begin : $a);
};
def.$begin = function(pos) {
var $a, $b, self = this;
if ((($a = ($b = pos['$=='](0)['$!'](), $b !== false && $b !== nil ?pos['$=='](1)['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "MatchData#begin only supports 0th element")};
return self.begin;
};
def.$captures = function() {
var self = this;
return self.matches.slice(1);
};
def.$inspect = function() {
var self = this;
var str = "#<MatchData " + (self.matches[0]).$inspect();
for (var i = 1, length = self.matches.length; i < length; i++) {
str += " " + i + ":" + (self.matches[i]).$inspect();
}
return str + ">";
;
};
def.$length = function() {
var self = this;
return self.matches.length;
};
Opal.defn(self, '$size', def.$length);
def.$to_a = function() {
var self = this;
return self.matches;
};
def.$to_s = function() {
var self = this;
return self.matches[0];
};
return (def.$values_at = function(indexes) {
var self = this;
indexes = $slice.call(arguments, 0);
var values = [],
match_length = self.matches.length;
for (var i = 0, length = indexes.length; i < length; i++) {
var pos = indexes[i];
if (pos >= 0) {
values.push(self.matches[pos]);
}
else {
pos += match_length;
if (pos > 0) {
values.push(self.matches[pos]);
}
else {
values.push(nil);
}
}
}
return values;
;
}, nil) && 'values_at';
})(self, null)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/numeric"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$require', '$include', '$coerce', '$===', '$raise', '$class', '$__send__', '$send_coerced', '$coerce_to!', '$-@', '$**', '$-', '$respond_to?', '$==', '$enum_for', '$gcd', '$lcm', '$<', '$>', '$floor', '$/', '$%']);
self.$require("corelib/comparable");
(function($base, $super) {
function $Numeric(){};
var self = $Numeric = $klass($base, $super, 'Numeric', $Numeric);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_6;
self.$include($scope.get('Comparable'));
def.$$is_number = true;
def.$coerce = function(other, type) {
var self = this, $case = nil;
if (type == null) {
type = "operation"
}
try {
if (other.$$is_number) {
return [self, other];
}
else {
return other.$coerce(self);
}
} catch ($err) {if (true) {
return (function() {$case = type;if ("operation"['$===']($case)) {return self.$raise($scope.get('TypeError'), "" + (other.$class()) + " can't be coerced into Numeric")}else if ("comparison"['$===']($case)) {return self.$raise($scope.get('ArgumentError'), "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed")}else { return nil }})()
}else { throw $err; }
};
};
def.$send_coerced = function(method, other) {
var $a, self = this, type = nil, $case = nil, a = nil, b = nil;
type = (function() {$case = method;if ("+"['$===']($case) || "-"['$===']($case) || "*"['$===']($case) || "/"['$===']($case) || "%"['$===']($case) || "&"['$===']($case) || "|"['$===']($case) || "^"['$===']($case) || "**"['$===']($case)) {return "operation"}else if (">"['$===']($case) || ">="['$===']($case) || "<"['$===']($case) || "<="['$===']($case) || "<=>"['$===']($case)) {return "comparison"}else { return nil }})();
$a = Opal.to_ary(self.$coerce(other, type)), a = ($a[0] == null ? nil : $a[0]), b = ($a[1] == null ? nil : $a[1]);
return a.$__send__(method, b);
};
def['$+'] = function(other) {
var self = this;
if (other.$$is_number) {
return self + other;
}
else {
return self.$send_coerced("+", other);
}
};
def['$-'] = function(other) {
var self = this;
if (other.$$is_number) {
return self - other;
}
else {
return self.$send_coerced("-", other);
}
};
def['$*'] = function(other) {
var self = this;
if (other.$$is_number) {
return self * other;
}
else {
return self.$send_coerced("*", other);
}
};
def['$/'] = function(other) {
var self = this;
if (other.$$is_number) {
return self / other;
}
else {
return self.$send_coerced("/", other);
}
};
def['$%'] = function(other) {
var self = this;
if (other.$$is_number) {
if (other < 0 || self < 0) {
return (self % other + other) % other;
}
else {
return self % other;
}
}
else {
return self.$send_coerced("%", other);
}
};
def['$&'] = function(other) {
var self = this;
if (other.$$is_number) {
return self & other;
}
else {
return self.$send_coerced("&", other);
}
};
def['$|'] = function(other) {
var self = this;
if (other.$$is_number) {
return self | other;
}
else {
return self.$send_coerced("|", other);
}
};
def['$^'] = function(other) {
var self = this;
if (other.$$is_number) {
return self ^ other;
}
else {
return self.$send_coerced("^", other);
}
};
def['$<'] = function(other) {
var self = this;
if (other.$$is_number) {
return self < other;
}
else {
return self.$send_coerced("<", other);
}
};
def['$<='] = function(other) {
var self = this;
if (other.$$is_number) {
return self <= other;
}
else {
return self.$send_coerced("<=", other);
}
};
def['$>'] = function(other) {
var self = this;
if (other.$$is_number) {
return self > other;
}
else {
return self.$send_coerced(">", other);
}
};
def['$>='] = function(other) {
var self = this;
if (other.$$is_number) {
return self >= other;
}
else {
return self.$send_coerced(">=", other);
}
};
def['$<=>'] = function(other) {
var self = this;
try {
if (other.$$is_number) {
return self > other ? 1 : (self < other ? -1 : 0);
}
else {
return self.$send_coerced("<=>", other);
}
} catch ($err) {if (Opal.rescue($err, [$scope.get('ArgumentError')])) {
return nil
}else { throw $err; }
};
};
def['$<<'] = function(count) {
var self = this;
count = $scope.get('Opal')['$coerce_to!'](count, $scope.get('Integer'), "to_int");
return count > 0 ? self << count : self >> -count;
};
def['$>>'] = function(count) {
var self = this;
count = $scope.get('Opal')['$coerce_to!'](count, $scope.get('Integer'), "to_int");
return count > 0 ? self >> count : self << -count;
};
def['$[]'] = function(bit) {
var self = this, min = nil, max = nil;
bit = $scope.get('Opal')['$coerce_to!'](bit, $scope.get('Integer'), "to_int");
min = ((2)['$**'](30))['$-@']();
max = ((2)['$**'](30))['$-'](1);
return (bit < min || bit > max) ? 0 : (self >> bit) % 2;
};
def['$+@'] = function() {
var self = this;
return +self;
};
def['$-@'] = function() {
var self = this;
return -self;
};
def['$~'] = function() {
var self = this;
return ~self;
};
def['$**'] = function(other) {
var self = this;
if (other.$$is_number) {
return Math.pow(self, other);
}
else {
return self.$send_coerced("**", other);
}
};
def['$=='] = function(other) {
var self = this;
if (other.$$is_number) {
return self == Number(other);
}
else if (other['$respond_to?']("==")) {
return other['$=='](self);
}
else {
return false;
}
;
};
def.$abs = function() {
var self = this;
return Math.abs(self);
};
def.$ceil = function() {
var self = this;
return Math.ceil(self);
};
def.$chr = function(encoding) {
var self = this;
return String.fromCharCode(self);
};
def.$conj = function() {
var self = this;
return self;
};
Opal.defn(self, '$conjugate', def.$conj);
def.$downto = TMP_1 = function(finish) {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
TMP_1.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("downto", finish)
};
for (var i = self; i >= finish; i--) {
if (block(i) === $breaker) {
return $breaker.$v;
}
}
return self;
};
Opal.defn(self, '$eql?', def['$==']);
Opal.defn(self, '$equal?', def['$==']);
def['$even?'] = function() {
var self = this;
return self % 2 === 0;
};
def.$floor = function() {
var self = this;
return Math.floor(self);
};
def.$gcd = function(other) {
var $a, self = this;
if ((($a = $scope.get('Integer')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('TypeError'), "not an integer")
};
var min = Math.abs(self),
max = Math.abs(other);
while (min > 0) {
var tmp = min;
min = max % min;
max = tmp;
}
return max;
};
def.$gcdlcm = function(other) {
var self = this;
return [self.$gcd(), self.$lcm()];
};
def.$hash = function() {
var self = this;
return 'Numeric:'+self.toString();
};
def['$integer?'] = function() {
var self = this;
return self % 1 === 0;
};
def['$is_a?'] = TMP_2 = function(klass) {var $zuper = $slice.call(arguments, 0);
var $a, $b, self = this, $iter = TMP_2.$$p, $yield = $iter || nil;
TMP_2.$$p = null;
if ((($a = (($b = klass['$==']($scope.get('Fixnum'))) ? $scope.get('Integer')['$==='](self) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
if ((($a = (($b = klass['$==']($scope.get('Integer'))) ? $scope.get('Integer')['$==='](self) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
if ((($a = (($b = klass['$==']($scope.get('Float'))) ? $scope.get('Float')['$==='](self) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
return Opal.find_super_dispatcher(self, 'is_a?', TMP_2, $iter).apply(self, $zuper);
};
Opal.defn(self, '$kind_of?', def['$is_a?']);
def['$instance_of?'] = TMP_3 = function(klass) {var $zuper = $slice.call(arguments, 0);
var $a, $b, self = this, $iter = TMP_3.$$p, $yield = $iter || nil;
TMP_3.$$p = null;
if ((($a = (($b = klass['$==']($scope.get('Fixnum'))) ? $scope.get('Integer')['$==='](self) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
if ((($a = (($b = klass['$==']($scope.get('Integer'))) ? $scope.get('Integer')['$==='](self) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
if ((($a = (($b = klass['$==']($scope.get('Float'))) ? $scope.get('Float')['$==='](self) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
return true};
return Opal.find_super_dispatcher(self, 'instance_of?', TMP_3, $iter).apply(self, $zuper);
};
def.$lcm = function(other) {
var $a, self = this;
if ((($a = $scope.get('Integer')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('TypeError'), "not an integer")
};
if (self == 0 || other == 0) {
return 0;
}
else {
return Math.abs(self * other / self.$gcd(other));
}
};
Opal.defn(self, '$magnitude', def.$abs);
Opal.defn(self, '$modulo', def['$%']);
def.$next = function() {
var self = this;
return self + 1;
};
def['$nonzero?'] = function() {
var self = this;
return self == 0 ? nil : self;
};
def['$odd?'] = function() {
var self = this;
return self % 2 !== 0;
};
def.$ord = function() {
var self = this;
return self;
};
def.$pred = function() {
var self = this;
return self - 1;
};
def.$round = function(ndigits) {
var self = this;
if (ndigits == null) {
ndigits = 0
}
var scale = Math.pow(10, ndigits);
return Math.round(self * scale) / scale;
};
def.$step = TMP_4 = function(limit, step) {
var $a, self = this, $iter = TMP_4.$$p, block = $iter || nil;
if (step == null) {
step = 1
}
TMP_4.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("step", limit, step)
};
if ((($a = step == 0) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "step cannot be 0")};
var value = self;
if (step > 0) {
while (value <= limit) {
block(value);
value += step;
}
}
else {
while (value >= limit) {
block(value);
value += step;
}
}
return self;
};
Opal.defn(self, '$succ', def.$next);
def.$times = TMP_5 = function() {
var self = this, $iter = TMP_5.$$p, block = $iter || nil;
TMP_5.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("times")
};
for (var i = 0; i < self; i++) {
if (block(i) === $breaker) {
return $breaker.$v;
}
}
return self;
};
def.$to_f = function() {
var self = this;
return self;
};
def.$to_i = function() {
var self = this;
return parseInt(self);
};
Opal.defn(self, '$to_int', def.$to_i);
def.$to_s = function(base) {
var $a, $b, self = this;
if (base == null) {
base = 10
}
if ((($a = ((($b = base['$<'](2)) !== false && $b !== nil) ? $b : base['$>'](36))) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('ArgumentError'), "base must be between 2 and 36")};
return self.toString(base);
};
Opal.defn(self, '$inspect', def.$to_s);
def.$divmod = function(rhs) {
var self = this, q = nil, r = nil;
q = (self['$/'](rhs)).$floor();
r = self['$%'](rhs);
return [q, r];
};
def.$upto = TMP_6 = function(finish) {
var self = this, $iter = TMP_6.$$p, block = $iter || nil;
TMP_6.$$p = null;
if (block !== false && block !== nil) {
} else {
return self.$enum_for("upto", finish)
};
for (var i = self; i <= finish; i++) {
if (block(i) === $breaker) {
return $breaker.$v;
}
}
return self;
};
def['$zero?'] = function() {
var self = this;
return self == 0;
};
def.$size = function() {
var self = this;
return 4;
};
def['$nan?'] = function() {
var self = this;
return isNaN(self);
};
def['$finite?'] = function() {
var self = this;
return self != Infinity && self != -Infinity;
};
def['$infinite?'] = function() {
var self = this;
if (self == Infinity) {
return +1;
}
else if (self == -Infinity) {
return -1;
}
else {
return nil;
}
};
def['$positive?'] = function() {
var self = this;
return 1 / self > 0;
};
return (def['$negative?'] = function() {
var self = this;
return 1 / self < 0;
}, nil) && 'negative?';
})(self, null);
Opal.cdecl($scope, 'Fixnum', $scope.get('Numeric'));
(function($base, $super) {
function $Integer(){};
var self = $Integer = $klass($base, $super, 'Integer', $Integer);
var def = self.$$proto, $scope = self.$$scope;
return (Opal.defs(self, '$===', function(other) {
var self = this;
if (!other.$$is_number) {
return false;
}
return (other % 1) === 0;
}), nil) && '==='
})(self, $scope.get('Numeric'));
return (function($base, $super) {
function $Float(){};
var self = $Float = $klass($base, $super, 'Float', $Float);
var def = self.$$proto, $scope = self.$$scope, $a;
Opal.defs(self, '$===', function(other) {
var self = this;
return !!other.$$is_number;
});
Opal.cdecl($scope, 'INFINITY', Infinity);
Opal.cdecl($scope, 'NAN', NaN);
if ((($a = (typeof(Number.EPSILON) !== "undefined")) !== nil && (!$a.$$is_boolean || $a == true))) {
return Opal.cdecl($scope, 'EPSILON', Number.EPSILON)
} else {
return Opal.cdecl($scope, 'EPSILON', 2.2204460492503130808472633361816E-16)
};
})(self, $scope.get('Numeric'));
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/complex"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
return (function($base, $super) {
function $Complex(){};
var self = $Complex = $klass($base, $super, 'Complex', $Complex);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Numeric'))
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/rational"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
return (function($base, $super) {
function $Rational(){};
var self = $Rational = $klass($base, $super, 'Rational', $Rational);
var def = self.$$proto, $scope = self.$$scope;
return nil;
})(self, $scope.get('Numeric'))
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/proc"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$raise']);
return (function($base, $super) {
function $Proc(){};
var self = $Proc = $klass($base, $super, 'Proc', $Proc);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2;
def.$$is_proc = true;
def.$$is_lambda = false;
Opal.defs(self, '$new', TMP_1 = function() {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
TMP_1.$$p = null;
if (block !== false && block !== nil) {
} else {
self.$raise($scope.get('ArgumentError'), "tried to create a Proc object without a block")
};
return block;
});
def.$call = TMP_2 = function(args) {
var self = this, $iter = TMP_2.$$p, block = $iter || nil;
args = $slice.call(arguments, 0);
TMP_2.$$p = null;
if (block !== nil) {
self.$$p = block;
}
var result;
if (self.$$is_lambda) {
result = self.apply(null, args);
}
else {
result = Opal.yieldX(self, args);
}
if (result === $breaker) {
return $breaker.$v;
}
return result;
};
Opal.defn(self, '$[]', def.$call);
def.$to_proc = function() {
var self = this;
return self;
};
def['$lambda?'] = function() {
var self = this;
return !!self.$$is_lambda;
};
return (def.$arity = function() {
var self = this;
return self.length;
}, nil) && 'arity';
})(self, null)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/method"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$attr_reader', '$class', '$arity', '$new', '$name']);
(function($base, $super) {
function $Method(){};
var self = $Method = $klass($base, $super, 'Method', $Method);
var def = self.$$proto, $scope = self.$$scope, TMP_1;
def.method = def.receiver = def.owner = def.name = def.obj = nil;
self.$attr_reader("owner", "receiver", "name");
def.$initialize = function(receiver, method, name) {
var self = this;
self.receiver = receiver;
self.owner = receiver.$class();
self.name = name;
return self.method = method;
};
def.$arity = function() {
var self = this;
return self.method.$arity();
};
def.$call = TMP_1 = function(args) {
var self = this, $iter = TMP_1.$$p, block = $iter || nil;
args = $slice.call(arguments, 0);
TMP_1.$$p = null;
self.method.$$p = block;
return self.method.apply(self.receiver, args);
;
};
Opal.defn(self, '$[]', def.$call);
def.$unbind = function() {
var self = this;
return $scope.get('UnboundMethod').$new(self.owner, self.method, self.name);
};
def.$to_proc = function() {
var self = this;
return self.method;
};
return (def.$inspect = function() {
var self = this;
return "#<Method: " + (self.obj.$class()) + "#" + (self.name) + "}>";
}, nil) && 'inspect';
})(self, null);
return (function($base, $super) {
function $UnboundMethod(){};
var self = $UnboundMethod = $klass($base, $super, 'UnboundMethod', $UnboundMethod);
var def = self.$$proto, $scope = self.$$scope;
def.method = def.name = def.owner = nil;
self.$attr_reader("owner", "name");
def.$initialize = function(owner, method, name) {
var self = this;
self.owner = owner;
self.method = method;
return self.name = name;
};
def.$arity = function() {
var self = this;
return self.method.$arity();
};
def.$bind = function(object) {
var self = this;
return $scope.get('Method').$new(object, self.method, self.name);
};
return (def.$inspect = function() {
var self = this;
return "#<UnboundMethod: " + (self.owner.$name()) + "#" + (self.name) + ">";
}, nil) && 'inspect';
})(self, null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/range"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$require', '$include', '$attr_reader', '$<=>', '$raise', '$include?', '$<=', '$<', '$enum_for', '$succ', '$!', '$==', '$===', '$exclude_end?', '$eql?', '$begin', '$end', '$-', '$abs', '$to_i', '$inspect']);
self.$require("corelib/enumerable");
return (function($base, $super) {
function $Range(){};
var self = $Range = $klass($base, $super, 'Range', $Range);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_2, TMP_3;
def.begin = def.exclude = def.end = nil;
self.$include($scope.get('Enumerable'));
def.$$is_range = true;
self.$attr_reader("begin", "end");
def.$initialize = function(first, last, exclude) {
var $a, self = this;
if (exclude == null) {
exclude = false
}
if ((($a = first['$<=>'](last)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'))
};
self.begin = first;
self.end = last;
return self.exclude = exclude;
};
def['$=='] = function(other) {
var self = this;
if (!other.$$is_range) {
return false;
}
return self.exclude === other.exclude &&
self.begin == other.begin &&
self.end == other.end;
};
def['$==='] = function(value) {
var self = this;
return self['$include?'](value);
};
def['$cover?'] = function(value) {
var $a, $b, self = this;
return (($a = self.begin['$<='](value)) ? ((function() {if ((($b = self.exclude) !== nil && (!$b.$$is_boolean || $b == true))) {
return value['$<'](self.end)
} else {
return value['$<='](self.end)
}; return nil; })()) : $a);
};
def.$each = TMP_1 = function() {
var $a, $b, self = this, $iter = TMP_1.$$p, block = $iter || nil, current = nil, last = nil;
TMP_1.$$p = null;
if ((block !== nil)) {
} else {
return self.$enum_for("each")
};
current = self.begin;
last = self.end;
while (current['$<'](last)) {
if (Opal.yield1(block, current) === $breaker) return $breaker.$v;
current = current.$succ();};
if ((($a = ($b = self.exclude['$!'](), $b !== false && $b !== nil ?current['$=='](last) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
if (Opal.yield1(block, current) === $breaker) return $breaker.$v};
return self;
};
def['$eql?'] = function(other) {
var $a, $b, self = this;
if ((($a = $scope.get('Range')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return false
};
return ($a = ($b = self.exclude['$==='](other['$exclude_end?']()), $b !== false && $b !== nil ?self.begin['$eql?'](other.$begin()) : $b), $a !== false && $a !== nil ?self.end['$eql?'](other.$end()) : $a);
};
def['$exclude_end?'] = function() {
var self = this;
return self.exclude;
};
Opal.defn(self, '$first', def.$begin);
Opal.defn(self, '$include?', def['$cover?']);
Opal.defn(self, '$last', def.$end);
def.$max = TMP_2 = function() {var $zuper = $slice.call(arguments, 0);
var self = this, $iter = TMP_2.$$p, $yield = $iter || nil;
TMP_2.$$p = null;
if (($yield !== nil)) {
return Opal.find_super_dispatcher(self, 'max', TMP_2, $iter).apply(self, $zuper)
} else {
return self.exclude ? self.end - 1 : self.end;
};
};
Opal.defn(self, '$member?', def['$cover?']);
def.$min = TMP_3 = function() {var $zuper = $slice.call(arguments, 0);
var self = this, $iter = TMP_3.$$p, $yield = $iter || nil;
TMP_3.$$p = null;
if (($yield !== nil)) {
return Opal.find_super_dispatcher(self, 'min', TMP_3, $iter).apply(self, $zuper)
} else {
return self.begin
};
};
Opal.defn(self, '$member?', def['$include?']);
def.$size = function() {
var $a, $b, self = this, _begin = nil, _end = nil, infinity = nil;
_begin = self.begin;
_end = self.end;
if ((($a = self.exclude) !== nil && (!$a.$$is_boolean || $a == true))) {
_end = _end['$-'](1)};
if ((($a = ($b = $scope.get('Numeric')['$==='](_begin), $b !== false && $b !== nil ?$scope.get('Numeric')['$==='](_end) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
return nil
};
if (_end['$<'](_begin)) {
return 0};
infinity = (($scope.get('Float')).$$scope.get('INFINITY'));
if ((($a = ((($b = infinity['$=='](_begin.$abs())) !== false && $b !== nil) ? $b : _end.$abs()['$=='](infinity))) !== nil && (!$a.$$is_boolean || $a == true))) {
return infinity};
return ((Math.abs(_end - _begin) + 1)).$to_i();
};
def.$step = function(n) {
var self = this;
if (n == null) {
n = 1
}
return self.$raise($scope.get('NotImplementedError'));
};
def.$to_s = function() {
var self = this;
return self.begin.$inspect() + (self.exclude ? '...' : '..') + self.end.$inspect();
};
return Opal.defn(self, '$inspect', def.$to_s);
})(self, null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/time"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $range = Opal.range;
Opal.add_stubs(['$require', '$include', '$kind_of?', '$to_i', '$coerce_to', '$between?', '$raise', '$new', '$compact', '$nil?', '$===', '$<=>', '$to_f', '$strftime', '$is_a?', '$zero?', '$wday', '$utc?', '$warn', '$year', '$mon', '$day', '$yday', '$hour', '$min', '$sec', '$rjust', '$ljust', '$zone', '$to_s', '$[]', '$cweek_cyear', '$month', '$isdst', '$private', '$<=', '$!', '$==', '$-', '$ceil', '$/', '$+']);
self.$require("corelib/comparable");
return (function($base, $super) {
function $Time(){};
var self = $Time = $klass($base, $super, 'Time', $Time);
var def = self.$$proto, $scope = self.$$scope;
def.tz_offset = nil;
self.$include($scope.get('Comparable'));
var days_of_week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
short_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
short_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
long_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
;
Opal.defs(self, '$at', function(seconds, frac) {
var self = this;
if (frac == null) {
frac = 0
}
return new Date(seconds * 1000 + frac);
});
Opal.defs(self, '$new', function(year, month, day, hour, minute, second, utc_offset) {
var self = this;
switch (arguments.length) {
case 1:
return new Date(year, 0);
case 2:
return new Date(year, month - 1);
case 3:
return new Date(year, month - 1, day);
case 4:
return new Date(year, month - 1, day, hour);
case 5:
return new Date(year, month - 1, day, hour, minute);
case 6:
return new Date(year, month - 1, day, hour, minute, second);
case 7:
return new Date(year, month - 1, day, hour, minute, second);
default:
return new Date();
}
});
Opal.defs(self, '$local', function(year, month, day, hour, minute, second, millisecond) {
var $a, self = this;
if (month == null) {
month = nil
}
if (day == null) {
day = nil
}
if (hour == null) {
hour = nil
}
if (minute == null) {
minute = nil
}
if (second == null) {
second = nil
}
if (millisecond == null) {
millisecond = nil
}
if ((($a = arguments.length === 10) !== nil && (!$a.$$is_boolean || $a == true))) {
var args = $slice.call(arguments).reverse();
second = args[9];
minute = args[8];
hour = args[7];
day = args[6];
month = args[5];
year = args[4];
};
year = (function() {if ((($a = year['$kind_of?']($scope.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
return year.$to_i()
} else {
return $scope.get('Opal').$coerce_to(year, $scope.get('Integer'), "to_int")
}; return nil; })();
month = (function() {if ((($a = month['$kind_of?']($scope.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
return month.$to_i()
} else {
return $scope.get('Opal').$coerce_to(((($a = month) !== false && $a !== nil) ? $a : 1), $scope.get('Integer'), "to_int")
}; return nil; })();
if ((($a = month['$between?'](1, 12)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "month out of range: " + (month))
};
day = (function() {if ((($a = day['$kind_of?']($scope.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
return day.$to_i()
} else {
return $scope.get('Opal').$coerce_to(((($a = day) !== false && $a !== nil) ? $a : 1), $scope.get('Integer'), "to_int")
}; return nil; })();
if ((($a = day['$between?'](1, 31)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "day out of range: " + (day))
};
hour = (function() {if ((($a = hour['$kind_of?']($scope.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
return hour.$to_i()
} else {
return $scope.get('Opal').$coerce_to(((($a = hour) !== false && $a !== nil) ? $a : 0), $scope.get('Integer'), "to_int")
}; return nil; })();
if ((($a = hour['$between?'](0, 24)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "hour out of range: " + (hour))
};
minute = (function() {if ((($a = minute['$kind_of?']($scope.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
return minute.$to_i()
} else {
return $scope.get('Opal').$coerce_to(((($a = minute) !== false && $a !== nil) ? $a : 0), $scope.get('Integer'), "to_int")
}; return nil; })();
if ((($a = minute['$between?'](0, 59)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "minute out of range: " + (minute))
};
second = (function() {if ((($a = second['$kind_of?']($scope.get('String'))) !== nil && (!$a.$$is_boolean || $a == true))) {
return second.$to_i()
} else {
return $scope.get('Opal').$coerce_to(((($a = second) !== false && $a !== nil) ? $a : 0), $scope.get('Integer'), "to_int")
}; return nil; })();
if ((($a = second['$between?'](0, 59)) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('ArgumentError'), "second out of range: " + (second))
};
return ($a = self).$new.apply($a, [].concat([year, month, day, hour, minute, second].$compact()));
});
Opal.defs(self, '$gm', function(year, month, day, hour, minute, second, utc_offset) {
var $a, self = this;
if ((($a = year['$nil?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('TypeError'), "missing year (got nil)")};
if (month > 12 || day > 31 || hour > 24 || minute > 59 || second > 59) {
self.$raise($scope.get('ArgumentError'));
}
var date = new Date(Date.UTC(year, (month || 1) - 1, (day || 1), (hour || 0), (minute || 0), (second || 0)));
date.tz_offset = 0
return date;
;
});
(function(self) {
var $scope = self.$$scope, def = self.$$proto;
self.$$proto.$mktime = self.$$proto.$local;
return self.$$proto.$utc = self.$$proto.$gm;
})(self.$singleton_class());
Opal.defs(self, '$now', function() {
var self = this;
return new Date();
});
def['$+'] = function(other) {
var $a, self = this;
if ((($a = $scope.get('Time')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$raise($scope.get('TypeError'), "time + time?")};
other = $scope.get('Opal').$coerce_to(other, $scope.get('Integer'), "to_int");
var result = new Date(self.getTime() + (other * 1000));
result.tz_offset = self.tz_offset;
return result;
};
def['$-'] = function(other) {
var $a, self = this;
if ((($a = $scope.get('Time')['$==='](other)) !== nil && (!$a.$$is_boolean || $a == true))) {
return (self.getTime() - other.getTime()) / 1000};
other = $scope.get('Opal').$coerce_to(other, $scope.get('Integer'), "to_int");
var result = new Date(self.getTime() - (other * 1000));
result.tz_offset = self.tz_offset;
return result;
};
def['$<=>'] = function(other) {
var self = this;
return self.$to_f()['$<=>'](other.$to_f());
};
def['$=='] = function(other) {
var self = this;
return self.$to_f() === other.$to_f();
};
def.$asctime = function() {
var self = this;
return self.$strftime("%a %b %e %H:%M:%S %Y");
};
Opal.defn(self, '$ctime', def.$asctime);
def.$day = function() {
var self = this;
if (self.tz_offset === 0) {
return self.getUTCDate();
}
else {
return self.getDate();
}
;
};
def.$yday = function() {
var self = this;
// http://javascript.about.com/library/bldayyear.htm
var onejan = new Date(self.getFullYear(), 0, 1);
return Math.ceil((self - onejan) / 86400000);
};
def.$isdst = function() {
var self = this;
return self.$raise($scope.get('NotImplementedError'));
};
def['$eql?'] = function(other) {
var $a, self = this;
return ($a = other['$is_a?']($scope.get('Time')), $a !== false && $a !== nil ?(self['$<=>'](other))['$zero?']() : $a);
};
def['$friday?'] = function() {
var self = this;
return self.$wday() == 5;
};
def.$hour = function() {
var self = this;
if (self.tz_offset === 0) {
return self.getUTCHours();
}
else {
return self.getHours();
}
;
};
def.$inspect = function() {
var $a, self = this;
if ((($a = self['$utc?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
return self.$strftime("%Y-%m-%d %H:%M:%S UTC")
} else {
return self.$strftime("%Y-%m-%d %H:%M:%S %z")
};
};
Opal.defn(self, '$mday', def.$day);
def.$min = function() {
var self = this;
if (self.tz_offset === 0) {
return self.getUTCMinutes();
}
else {
return self.getMinutes();
}
;
};
def.$mon = function() {
var self = this;
if (self.tz_offset === 0) {
return self.getUTCMonth() + 1;
}
else {
return self.getMonth() + 1;
}
;
};
def['$monday?'] = function() {
var self = this;
return self.$wday() == 1;
};
Opal.defn(self, '$month', def.$mon);
def['$saturday?'] = function() {
var self = this;
return self.$wday() == 6;
};
def.$sec = function() {
var self = this;
if (self.tz_offset === 0) {
return self.getUTCSeconds();
}
else {
return self.getSeconds();
}
;
};
def.$usec = function() {
var self = this;
self.$warn("Microseconds are not supported");
return 0;
};
def.$zone = function() {
var self = this;
var string = self.toString(),
result;
if (string.indexOf('(') == -1) {
result = string.match(/[A-Z]{3,4}/)[0];
}
else {
result = string.match(/\([^)]+\)/)[0].match(/[A-Z]/g).join('');
}
if (result == "GMT" && /(GMT\W*\d{4})/.test(string)) {
return RegExp.$1;
}
else {
return result;
}
};
def.$getgm = function() {
var self = this;
var result = new Date(self.getTime());
result.tz_offset = 0;
return result;
};
def['$gmt?'] = function() {
var self = this;
return self.tz_offset === 0;
};
def.$gmt_offset = function() {
var self = this;
return -self.getTimezoneOffset() * 60;
};
def.$strftime = function(format) {
var self = this;
return format.replace(/%([\-_#^0]*:{0,2})(\d+)?([EO]*)(.)/g, function(full, flags, width, _, conv) {
var result = "",
width = parseInt(width),
zero = flags.indexOf('0') !== -1,
pad = flags.indexOf('-') === -1,
blank = flags.indexOf('_') !== -1,
upcase = flags.indexOf('^') !== -1,
invert = flags.indexOf('#') !== -1,
colons = (flags.match(':') || []).length;
if (zero && blank) {
if (flags.indexOf('0') < flags.indexOf('_')) {
zero = false;
}
else {
blank = false;
}
}
switch (conv) {
case 'Y':
result += self.$year();
break;
case 'C':
zero = !blank;
result += Math.round(self.$year() / 100);
break;
case 'y':
zero = !blank;
result += (self.$year() % 100);
break;
case 'm':
zero = !blank;
result += self.$mon();
break;
case 'B':
result += long_months[self.$mon() - 1];
break;
case 'b':
case 'h':
blank = !zero;
result += short_months[self.$mon() - 1];
break;
case 'd':
zero = !blank
result += self.$day();
break;
case 'e':
blank = !zero
result += self.$day();
break;
case 'j':
result += self.$yday();
break;
case 'H':
zero = !blank;
result += self.$hour();
break;
case 'k':
blank = !zero;
result += self.$hour();
break;
case 'I':
zero = !blank;
result += (self.$hour() % 12 || 12);
break;
case 'l':
blank = !zero;
result += (self.$hour() % 12 || 12);
break;
case 'P':
result += (self.$hour() >= 12 ? "pm" : "am");
break;
case 'p':
result += (self.$hour() >= 12 ? "PM" : "AM");
break;
case 'M':
zero = !blank;
result += self.$min();
break;
case 'S':
zero = !blank;
result += self.$sec()
break;
case 'L':
zero = !blank;
width = isNaN(width) ? 3 : width;
result += self.getMilliseconds();
break;
case 'N':
width = isNaN(width) ? 9 : width;
result += (self.getMilliseconds().toString()).$rjust(3, "0");
result = (result).$ljust(width, "0");
break;
case 'z':
var offset = self.getTimezoneOffset(),
hours = Math.floor(Math.abs(offset) / 60),
minutes = Math.abs(offset) % 60;
result += offset < 0 ? "+" : "-";
result += hours < 10 ? "0" : "";
result += hours;
if (colons > 0) {
result += ":";
}
result += minutes < 10 ? "0" : "";
result += minutes;
if (colons > 1) {
result += ":00";
}
break;
case 'Z':
result += self.$zone();
break;
case 'A':
result += days_of_week[self.$wday()];
break;
case 'a':
result += short_days[self.$wday()];
break;
case 'u':
result += (self.$wday() + 1);
break;
case 'w':
result += self.$wday();
break;
case 'V':
result += self.$cweek_cyear()['$[]'](0).$to_s().$rjust(2, "0");
break;
case 'G':
result += self.$cweek_cyear()['$[]'](1);
break;
case 'g':
result += self.$cweek_cyear()['$[]'](1)['$[]']($range(-2, -1, false));
break;
case 's':
result += self.$to_i();
break;
case 'n':
result += "\n";
break;
case 't':
result += "\t";
break;
case '%':
result += "%";
break;
case 'c':
result += self.$strftime("%a %b %e %T %Y");
break;
case 'D':
case 'x':
result += self.$strftime("%m/%d/%y");
break;
case 'F':
result += self.$strftime("%Y-%m-%d");
break;
case 'v':
result += self.$strftime("%e-%^b-%4Y");
break;
case 'r':
result += self.$strftime("%I:%M:%S %p");
break;
case 'R':
result += self.$strftime("%H:%M");
break;
case 'T':
case 'X':
result += self.$strftime("%H:%M:%S");
break;
default:
return full;
}
if (upcase) {
result = result.toUpperCase();
}
if (invert) {
result = result.replace(/[A-Z]/, function(c) { c.toLowerCase() }).
replace(/[a-z]/, function(c) { c.toUpperCase() });
}
if (pad && (zero || blank)) {
result = (result).$rjust(isNaN(width) ? 2 : width, blank ? " " : "0");
}
return result;
});
};
def['$sunday?'] = function() {
var self = this;
return self.$wday() == 0;
};
def['$thursday?'] = function() {
var self = this;
return self.$wday() == 4;
};
def.$to_a = function() {
var self = this;
return [self.$sec(), self.$min(), self.$hour(), self.$day(), self.$month(), self.$year(), self.$wday(), self.$yday(), self.$isdst(), self.$zone()];
};
def.$to_f = function() {
var self = this;
return self.getTime() / 1000;
};
def.$to_i = function() {
var self = this;
return parseInt(self.getTime() / 1000);
};
Opal.defn(self, '$to_s', def.$inspect);
def['$tuesday?'] = function() {
var self = this;
return self.$wday() == 2;
};
Opal.defn(self, '$utc?', def['$gmt?']);
Opal.defn(self, '$utc_offset', def.$gmt_offset);
def.$wday = function() {
var self = this;
if (self.tz_offset === 0) {
return self.getUTCDay();
}
else {
return self.getDay();
}
;
};
def['$wednesday?'] = function() {
var self = this;
return self.$wday() == 3;
};
def.$year = function() {
var self = this;
if (self.tz_offset === 0) {
return self.getUTCFullYear();
}
else {
return self.getFullYear();
}
;
};
self.$private("cweek_cyear");
return (def.$cweek_cyear = function() {
var $a, $b, self = this, jan01 = nil, jan01_wday = nil, first_monday = nil, year = nil, offset = nil, week = nil, dec31 = nil, dec31_wday = nil;
jan01 = $scope.get('Time').$new(self.$year(), 1, 1);
jan01_wday = jan01.$wday();
first_monday = 0;
year = self.$year();
if ((($a = (($b = jan01_wday['$<='](4)) ? jan01_wday['$=='](0)['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
offset = jan01_wday['$-'](1)
} else {
offset = jan01_wday['$-'](7)['$-'](1);
if (offset['$=='](-8)) {
offset = -1};
};
week = ((self.$yday()['$+'](offset))['$/'](7.0)).$ceil();
if (week['$<='](0)) {
return $scope.get('Time').$new(self.$year()['$-'](1), 12, 31).$cweek_cyear()
} else if (week['$=='](53)) {
dec31 = $scope.get('Time').$new(self.$year(), 12, 31);
dec31_wday = dec31.$wday();
if ((($a = (($b = dec31_wday['$<='](3)) ? dec31_wday['$=='](0)['$!']() : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {
week = 1;
year = year['$+'](1);};};
return [week, year];
}, nil) && 'cweek_cyear';
})(self, null);
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/struct"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$==', '$[]', '$upcase', '$const_set', '$new', '$unshift', '$each', '$define_struct_attribute', '$instance_eval', '$to_proc', '$raise', '$<<', '$members', '$attr_accessor', '$include', '$each_with_index', '$instance_variable_set', '$class', '$===', '$>=', '$size', '$include?', '$to_sym', '$instance_variable_get', '$enum_for', '$hash', '$all?', '$length', '$map', '$+', '$join', '$inspect', '$each_pair']);
return (function($base, $super) {
function $Struct(){};
var self = $Struct = $klass($base, $super, 'Struct', $Struct);
var def = self.$$proto, $scope = self.$$scope, TMP_1, TMP_6, TMP_8;
Opal.defs(self, '$new', TMP_1 = function(name, args) {var $zuper = $slice.call(arguments, 0);
var $a, $b, $c, TMP_2, self = this, $iter = TMP_1.$$p, block = $iter || nil;
args = $slice.call(arguments, 1);
TMP_1.$$p = null;
if (self['$==']($scope.get('Struct'))) {
} else {
return Opal.find_super_dispatcher(self, 'new', TMP_1, $iter, $Struct).apply(self, $zuper)
};
if (name['$[]'](0)['$=='](name['$[]'](0).$upcase())) {
return $scope.get('Struct').$const_set(name, ($a = self).$new.apply($a, [].concat(args)))
} else {
args.$unshift(name);
return ($b = ($c = $scope.get('Class')).$new, $b.$$p = (TMP_2 = function(){var self = TMP_2.$$s || this, $a, $b, TMP_3, $c;
($a = ($b = args).$each, $a.$$p = (TMP_3 = function(arg){var self = TMP_3.$$s || this;
if (arg == null) arg = nil;
return self.$define_struct_attribute(arg)}, TMP_3.$$s = self, TMP_3), $a).call($b);
if (block !== false && block !== nil) {
return ($a = ($c = self).$instance_eval, $a.$$p = block.$to_proc(), $a).call($c)
} else {
return nil
};}, TMP_2.$$s = self, TMP_2), $b).call($c, self);
};
});
Opal.defs(self, '$define_struct_attribute', function(name) {
var self = this;
if (self['$==']($scope.get('Struct'))) {
self.$raise($scope.get('ArgumentError'), "you cannot define attributes to the Struct class")};
self.$members()['$<<'](name);
return self.$attr_accessor(name);
});
Opal.defs(self, '$members', function() {
var $a, self = this;
if (self.members == null) self.members = nil;
if (self['$==']($scope.get('Struct'))) {
self.$raise($scope.get('ArgumentError'), "the Struct class has no members")};
return ((($a = self.members) !== false && $a !== nil) ? $a : self.members = []);
});
Opal.defs(self, '$inherited', function(klass) {
var $a, $b, TMP_4, self = this, members = nil;
if (self.members == null) self.members = nil;
if (self['$==']($scope.get('Struct'))) {
return nil};
members = self.members;
return ($a = ($b = klass).$instance_eval, $a.$$p = (TMP_4 = function(){var self = TMP_4.$$s || this;
return self.members = members}, TMP_4.$$s = self, TMP_4), $a).call($b);
});
(function(self) {
var $scope = self.$$scope, def = self.$$proto;
return self.$$proto['$[]'] = self.$$proto.$new
})(self.$singleton_class());
self.$include($scope.get('Enumerable'));
def.$initialize = function(args) {
var $a, $b, TMP_5, self = this;
args = $slice.call(arguments, 0);
return ($a = ($b = self.$members()).$each_with_index, $a.$$p = (TMP_5 = function(name, index){var self = TMP_5.$$s || this;
if (name == null) name = nil;if (index == null) index = nil;
return self.$instance_variable_set("@" + (name), args['$[]'](index))}, TMP_5.$$s = self, TMP_5), $a).call($b);
};
def.$members = function() {
var self = this;
return self.$class().$members();
};
def['$[]'] = function(name) {
var $a, self = this;
if ((($a = $scope.get('Integer')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
if (name['$>='](self.$members().$size())) {
self.$raise($scope.get('IndexError'), "offset " + (name) + " too large for struct(size:" + (self.$members().$size()) + ")")};
name = self.$members()['$[]'](name);
} else if ((($a = self.$members()['$include?'](name.$to_sym())) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('NameError'), "no member '" + (name) + "' in struct")
};
return self.$instance_variable_get("@" + (name));
};
def['$[]='] = function(name, value) {
var $a, self = this;
if ((($a = $scope.get('Integer')['$==='](name)) !== nil && (!$a.$$is_boolean || $a == true))) {
if (name['$>='](self.$members().$size())) {
self.$raise($scope.get('IndexError'), "offset " + (name) + " too large for struct(size:" + (self.$members().$size()) + ")")};
name = self.$members()['$[]'](name);
} else if ((($a = self.$members()['$include?'](name.$to_sym())) !== nil && (!$a.$$is_boolean || $a == true))) {
} else {
self.$raise($scope.get('NameError'), "no member '" + (name) + "' in struct")
};
return self.$instance_variable_set("@" + (name), value);
};
def.$each = TMP_6 = function() {
var $a, $b, TMP_7, self = this, $iter = TMP_6.$$p, $yield = $iter || nil;
TMP_6.$$p = null;
if (($yield !== nil)) {
} else {
return self.$enum_for("each")
};
($a = ($b = self.$members()).$each, $a.$$p = (TMP_7 = function(name){var self = TMP_7.$$s || this, $a;
if (name == null) name = nil;
return $a = Opal.yield1($yield, self['$[]'](name)), $a === $breaker ? $a : $a}, TMP_7.$$s = self, TMP_7), $a).call($b);
return self;
};
def.$each_pair = TMP_8 = function() {
var $a, $b, TMP_9, self = this, $iter = TMP_8.$$p, $yield = $iter || nil;
TMP_8.$$p = null;
if (($yield !== nil)) {
} else {
return self.$enum_for("each_pair")
};
($a = ($b = self.$members()).$each, $a.$$p = (TMP_9 = function(name){var self = TMP_9.$$s || this, $a;
if (name == null) name = nil;
return $a = Opal.yieldX($yield, [name, self['$[]'](name)]), $a === $breaker ? $a : $a}, TMP_9.$$s = self, TMP_9), $a).call($b);
return self;
};
def['$eql?'] = function(other) {
var $a, $b, $c, TMP_10, self = this;
return ((($a = self.$hash()['$=='](other.$hash())) !== false && $a !== nil) ? $a : ($b = ($c = other.$each_with_index())['$all?'], $b.$$p = (TMP_10 = function(object, index){var self = TMP_10.$$s || this;
if (object == null) object = nil;if (index == null) index = nil;
return self['$[]'](self.$members()['$[]'](index))['$=='](object)}, TMP_10.$$s = self, TMP_10), $b).call($c));
};
def.$length = function() {
var self = this;
return self.$members().$length();
};
Opal.defn(self, '$size', def.$length);
def.$to_a = function() {
var $a, $b, TMP_11, self = this;
return ($a = ($b = self.$members()).$map, $a.$$p = (TMP_11 = function(name){var self = TMP_11.$$s || this;
if (name == null) name = nil;
return self['$[]'](name)}, TMP_11.$$s = self, TMP_11), $a).call($b);
};
Opal.defn(self, '$values', def.$to_a);
def.$inspect = function() {
var $a, $b, TMP_12, self = this, result = nil;
result = "#<struct ";
if (self.$class()['$==']($scope.get('Struct'))) {
result = result['$+']("" + (self.$class()) + " ")};
result = result['$+'](($a = ($b = self.$each_pair()).$map, $a.$$p = (TMP_12 = function(name, value){var self = TMP_12.$$s || this;
if (name == null) name = nil;if (value == null) value = nil;
return "" + (name) + "=" + (value.$inspect())}, TMP_12.$$s = self, TMP_12), $a).call($b).$join(", "));
result = result['$+'](">");
return result;
};
return Opal.defn(self, '$to_s', def.$inspect);
})(self, null)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/io"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var $a, $b, self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module, $gvars = Opal.gvars;
if ($gvars.stdout == null) $gvars.stdout = nil;
if ($gvars.stderr == null) $gvars.stderr = nil;
Opal.add_stubs(['$attr_accessor', '$size', '$write', '$join', '$map', '$String', '$empty?', '$concat', '$chomp', '$getbyte', '$getc', '$raise', '$new', '$write_proc=', '$extend']);
(function($base, $super) {
function $IO(){};
var self = $IO = $klass($base, $super, 'IO', $IO);
var def = self.$$proto, $scope = self.$$scope;
def.tty = def.closed = nil;
Opal.cdecl($scope, 'SEEK_SET', 0);
Opal.cdecl($scope, 'SEEK_CUR', 1);
Opal.cdecl($scope, 'SEEK_END', 2);
def['$tty?'] = function() {
var self = this;
return self.tty;
};
def['$closed?'] = function() {
var self = this;
return self.closed;
};
self.$attr_accessor("write_proc");
def.$write = function(string) {
var self = this;
self.write_proc(string);
return string.$size();
};
self.$attr_accessor("sync");
(function($base) {
var self = $module($base, 'Writable');
var def = self.$$proto, $scope = self.$$scope;
Opal.defn(self, '$<<', function(string) {
var self = this;
self.$write(string);
return self;
});
Opal.defn(self, '$print', function(args) {
var $a, $b, TMP_1, self = this;
if ($gvars[","] == null) $gvars[","] = nil;
args = $slice.call(arguments, 0);
self.$write(($a = ($b = args).$map, $a.$$p = (TMP_1 = function(arg){var self = TMP_1.$$s || this;
if (arg == null) arg = nil;
return self.$String(arg)}, TMP_1.$$s = self, TMP_1), $a).call($b).$join($gvars[","]));
return nil;
});
Opal.defn(self, '$puts', function(args) {
var $a, $b, TMP_2, self = this, newline = nil;
if ($gvars["/"] == null) $gvars["/"] = nil;
args = $slice.call(arguments, 0);
newline = $gvars["/"];
if ((($a = args['$empty?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
self.$write($gvars["/"])
} else {
self.$write(($a = ($b = args).$map, $a.$$p = (TMP_2 = function(arg){var self = TMP_2.$$s || this;
if (arg == null) arg = nil;
return self.$String(arg).$chomp()}, TMP_2.$$s = self, TMP_2), $a).call($b).$concat([nil]).$join(newline))
};
return nil;
});
})(self);
return (function($base) {
var self = $module($base, 'Readable');
var def = self.$$proto, $scope = self.$$scope;
Opal.defn(self, '$readbyte', function() {
var self = this;
return self.$getbyte();
});
Opal.defn(self, '$readchar', function() {
var self = this;
return self.$getc();
});
Opal.defn(self, '$readline', function(sep) {
var self = this;
if ($gvars["/"] == null) $gvars["/"] = nil;
if (sep == null) {
sep = $gvars["/"]
}
return self.$raise($scope.get('NotImplementedError'));
});
Opal.defn(self, '$readpartial', function(integer, outbuf) {
var self = this;
if (outbuf == null) {
outbuf = nil
}
return self.$raise($scope.get('NotImplementedError'));
});
})(self);
})(self, null);
Opal.cdecl($scope, 'STDERR', $gvars.stderr = $scope.get('IO').$new());
Opal.cdecl($scope, 'STDIN', $gvars.stdin = $scope.get('IO').$new());
Opal.cdecl($scope, 'STDOUT', $gvars.stdout = $scope.get('IO').$new());
(($a = [typeof(process) === 'object' ? function(s){process.stdout.write(s)} : function(s){console.log(s)}]), $b = $gvars.stdout, $b['$write_proc='].apply($b, $a), $a[$a.length-1]);
(($a = [typeof(process) === 'object' ? function(s){process.stderr.write(s)} : function(s){console.warn(s)}]), $b = $gvars.stderr, $b['$write_proc='].apply($b, $a), $a[$a.length-1]);
$gvars.stdout.$extend((($scope.get('IO')).$$scope.get('Writable')));
return $gvars.stderr.$extend((($scope.get('IO')).$$scope.get('Writable')));
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/main"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;
Opal.add_stubs(['$include']);
Opal.defs(self, '$to_s', function() {
var self = this;
return "main";
});
return (Opal.defs(self, '$include', function(mod) {
var self = this;
return $scope.get('Object').$include(mod);
}), nil) && 'include';
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/variables"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $gvars = Opal.gvars, $hash2 = Opal.hash2;
Opal.add_stubs(['$new']);
$gvars["&"] = $gvars["~"] = $gvars["`"] = $gvars["'"] = nil;
$gvars.LOADED_FEATURES = $gvars["\""] = Opal.loaded_features;
$gvars.LOAD_PATH = $gvars[":"] = [];
$gvars["/"] = "\n";
$gvars[","] = nil;
Opal.cdecl($scope, 'ARGV', []);
Opal.cdecl($scope, 'ARGF', $scope.get('Object').$new());
Opal.cdecl($scope, 'ENV', $hash2([], {}));
$gvars.VERBOSE = false;
$gvars.DEBUG = false;
$gvars.SAFE = 0;
Opal.cdecl($scope, 'RUBY_PLATFORM', "opal");
Opal.cdecl($scope, 'RUBY_ENGINE', "opal");
Opal.cdecl($scope, 'RUBY_VERSION', "2.1.1");
Opal.cdecl($scope, 'RUBY_ENGINE_VERSION', "0.6.1");
return Opal.cdecl($scope, 'RUBY_RELEASE_DATE', "2014-04-15");
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/dir"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass;
Opal.add_stubs(['$[]']);
return (function($base, $super) {
function $Dir(){};
var self = $Dir = $klass($base, $super, 'Dir', $Dir);
var def = self.$$proto, $scope = self.$$scope;
return (function(self) {
var $scope = self.$$scope, def = self.$$proto;
self.$$proto.$chdir = TMP_1 = function(dir) {
var $a, self = this, $iter = TMP_1.$$p, $yield = $iter || nil, prev_cwd = nil;
TMP_1.$$p = null;
try {
prev_cwd = Opal.current_dir;
Opal.current_dir = dir;
return $a = Opal.yieldX($yield, []), $a === $breaker ? $a : $a;
} finally {
Opal.current_dir = prev_cwd;
};
};
self.$$proto.$pwd = function() {
var self = this;
return Opal.current_dir || '.';
};
self.$$proto.$getwd = self.$$proto.$pwd;
return (self.$$proto.$home = function() {
var $a, self = this;
return ((($a = $scope.get('ENV')['$[]']("HOME")) !== false && $a !== nil) ? $a : ".");
}, nil) && 'home';
})(self.$singleton_class())
})(self, null)
};
/* Generated by Opal 0.7.1 */
Opal.modules["corelib/file"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $range = Opal.range;
Opal.add_stubs(['$join', '$compact', '$split', '$==', '$first', '$[]=', '$home', '$each', '$pop', '$<<', '$[]', '$gsub', '$find', '$=~']);
return (function($base, $super) {
function $File(){};
var self = $File = $klass($base, $super, 'File', $File);
var def = self.$$proto, $scope = self.$$scope;
Opal.cdecl($scope, 'Separator', Opal.cdecl($scope, 'SEPARATOR', "/"));
Opal.cdecl($scope, 'ALT_SEPARATOR', nil);
Opal.cdecl($scope, 'PATH_SEPARATOR', ":");
return (function(self) {
var $scope = self.$$scope, def = self.$$proto;
self.$$proto.$expand_path = function(path, basedir) {
var $a, $b, TMP_1, self = this, parts = nil, new_parts = nil;
if (basedir == null) {
basedir = nil
}
path = [basedir, path].$compact().$join($scope.get('SEPARATOR'));
parts = path.$split($scope.get('SEPARATOR'));
new_parts = [];
if (parts.$first()['$==']("~")) {
parts['$[]='](0, $scope.get('Dir').$home())};
($a = ($b = parts).$each, $a.$$p = (TMP_1 = function(part){var self = TMP_1.$$s || this;
if (part == null) part = nil;
if (part['$==']("..")) {
return new_parts.$pop()
} else {
return new_parts['$<<'](part)
}}, TMP_1.$$s = self, TMP_1), $a).call($b);
return new_parts.$join($scope.get('SEPARATOR'));
};
self.$$proto.$dirname = function(path) {
var self = this;
return self.$split(path)['$[]']($range(0, -2, false));
};
self.$$proto.$basename = function(path) {
var self = this;
return self.$split(path)['$[]'](-1);
};
self.$$proto['$exist?'] = function(path) {
var self = this;
return Opal.modules[path] != null;
};
self.$$proto['$exists?'] = self.$$proto['$exist?'];
self.$$proto['$directory?'] = function(path) {
var $a, $b, TMP_2, self = this, files = nil, file = nil;
files = [];
for (var key in Opal.modules) {
files.push(key)
}
;
path = path.$gsub((new RegExp("(^." + $scope.get('SEPARATOR') + "+|" + $scope.get('SEPARATOR') + "+$)")));
file = ($a = ($b = files).$find, $a.$$p = (TMP_2 = function(file){var self = TMP_2.$$s || this;
if (file == null) file = nil;
return file['$=~']((new RegExp("^" + path)))}, TMP_2.$$s = self, TMP_2), $a).call($b);
return file;
};
self.$$proto.$join = function(paths) {
var self = this;
paths = $slice.call(arguments, 0);
return paths.$join($scope.get('SEPARATOR')).$gsub((new RegExp("" + $scope.get('SEPARATOR') + "+")), $scope.get('SEPARATOR'));
};
return (self.$$proto.$split = function(path) {
var self = this;
return path.$split($scope.get('SEPARATOR'));
}, nil) && 'split';
})(self.$singleton_class());
})(self, $scope.get('IO'))
};
/* Generated by Opal 0.7.1 */
Opal.modules["opal"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice;
Opal.add_stubs(['$require']);
self.$require("corelib/runtime");
self.$require("corelib/helpers");
self.$require("corelib/module");
self.$require("corelib/class");
self.$require("corelib/basic_object");
self.$require("corelib/kernel");
self.$require("corelib/nil_class");
self.$require("corelib/boolean");
self.$require("corelib/error");
self.$require("corelib/regexp");
self.$require("corelib/comparable");
self.$require("corelib/enumerable");
self.$require("corelib/enumerator");
self.$require("corelib/array");
self.$require("corelib/array/inheritance");
self.$require("corelib/hash");
self.$require("corelib/string");
self.$require("corelib/string/inheritance");
self.$require("corelib/match_data");
self.$require("corelib/numeric");
self.$require("corelib/complex");
self.$require("corelib/rational");
self.$require("corelib/proc");
self.$require("corelib/method");
self.$require("corelib/range");
self.$require("corelib/time");
self.$require("corelib/struct");
self.$require("corelib/io");
self.$require("corelib/main");
self.$require("corelib/variables");
self.$require("corelib/dir");
return self.$require("corelib/file");
};
/*! jQuery v2.1.3 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.3",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=hb(),z=hb(),A=hb(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},eb=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fb){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function gb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+rb(o[l]);w=ab.test(a)&&pb(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function hb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ib(a){return a[u]=!0,a}function jb(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function kb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function lb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function nb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function ob(a){return ib(function(b){return b=+b,ib(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pb(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=gb.support={},f=gb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=gb.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",eb,!1):e.attachEvent&&e.attachEvent("onunload",eb)),p=!f(g),c.attributes=jb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=jb(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=jb(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(jb(function(a){o.appendChild(a).innerHTML="<a id='"+u+"'></a><select id='"+u+"-\f]' msallowcapture=''><option selected=''></option></select>",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),jb(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&jb(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return lb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?lb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},gb.matches=function(a,b){return gb(a,null,null,b)},gb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return gb(b,n,null,[a]).length>0},gb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},gb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},gb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},gb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=gb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=gb.selectors={cacheLength:50,createPseudo:ib,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||gb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&gb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=gb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||gb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ib(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ib(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ib(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ib(function(a){return function(b){return gb(a,b).length>0}}),contains:ib(function(a){return a=a.replace(cb,db),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ib(function(a){return W.test(a||"")||gb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:ob(function(){return[0]}),last:ob(function(a,b){return[b-1]}),eq:ob(function(a,b,c){return[0>c?c+b:c]}),even:ob(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:ob(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:ob(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:ob(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=mb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=nb(b);function qb(){}qb.prototype=d.filters=d.pseudos,d.setFilters=new qb,g=gb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?gb.error(a):z(a,i).slice(0)};function rb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function sb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function tb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ub(a,b,c){for(var d=0,e=b.length;e>d;d++)gb(a,b[d],c);return c}function vb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wb(a,b,c,d,e,f){return d&&!d[u]&&(d=wb(d)),e&&!e[u]&&(e=wb(e,f)),ib(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ub(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:vb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=vb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=vb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sb(function(a){return a===b},h,!0),l=sb(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sb(tb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wb(i>1&&tb(m),i>1&&rb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xb(a.slice(i,e)),f>e&&xb(a=a.slice(e)),f>e&&rb(a))}m.push(c)}return tb(m)}function yb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=vb(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&gb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ib(f):f}return h=gb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,yb(e,d)),f.selector=a}return f},i=gb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&pb(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&rb(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&pb(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=jb(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),jb(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||kb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&jb(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||kb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),jb(function(a){return null==a.getAttribute("disabled")})||kb(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),gb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)
},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=l.createDocumentFragment(),b=a.appendChild(l.createElement("div")),c=l.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||l,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[n.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new n.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=l),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&n.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return n.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=n.extend(new n.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?n.event.trigger(e,null,b):n.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},n.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},n.Event=function(a,b){return this instanceof n.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?Z:$):this.type=a,b&&n.extend(this,b),this.timeStamp=a&&a.timeStamp||n.now(),void(this[n.expando]=!0)):new n.Event(a,b)},n.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=Z,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},n.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){n.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!n.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.focusinBubbles||n.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){n.event.simulate(b,a.target,n.event.fix(a),!0)};n.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),n.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return n().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=n.guid++)),this.each(function(){n.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,n(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){n.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){n.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?n.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(b){return b.ownerDocument.defaultView.opener?b.ownerDocument.defaultView.getComputedStyle(b,null):a.getComputedStyle(b,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),f.removeChild(c),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:"0",fontWeight:"400"},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fb(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fb(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?zb.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=yb(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(n.cssHooks[a+b].set=Gb)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}n.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Kb.prototype.init,n.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=n.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||tb(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?tb(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ub(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return n.map(k,Ub,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xb,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xb(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),n.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Lb=n.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||n.fx.stop(),Lb=void 0},n.fx.timer=function(a){n.timers.push(a),a()?n.fx.start():n.timers.pop()},n.fx.interval=13,n.fx.start=function(){Mb||(Mb=setInterval(n.fx.tick,n.fx.interval))},n.fx.stop=function(){clearInterval(Mb),Mb=null},n.fx.speeds={slow:600,fast:200,_default:400},n.fn.delay=function(a,b){return a=n.fx?n.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=l.createElement("input"),b=l.createElement("select"),c=b.appendChild(l.createElement("option"));a.type="checkbox",k.checkOn=""!==a.value,k.optSelected=c.selected,b.disabled=!0,k.optDisabled=!c.disabled,a=l.createElement("input"),a.value="t",a.type="radio",k.radioValue="t"===a.value}();var Yb,Zb,$b=n.expr.attrHandle;n.fn.extend({attr:function(a,b){return J(this,n.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))
},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=n.now(),dc=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var ec=/#.*$/,fc=/([?&])_=[^&]*/,gc=/^(.*?):[ \t]*([^\r\n]*)$/gm,hc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,ic=/^(?:GET|HEAD)$/,jc=/^\/\//,kc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,lc={},mc={},nc="*/".concat("*"),oc=a.location.href,pc=kc.exec(oc.toLowerCase())||[];function qc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function rc(a,b,c,d){var e={},f=a===mc;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function sc(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function tc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function uc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:oc,type:"GET",isLocal:hc.test(pc[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":nc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?sc(sc(a,n.ajaxSettings),b):sc(n.ajaxSettings,a)},ajaxPrefilter:qc(lc),ajaxTransport:qc(mc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=gc.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||oc)+"").replace(ec,"").replace(jc,pc[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=kc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===pc[1]&&h[2]===pc[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(pc[3]||("http:"===pc[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),rc(lc,k,b,v),2===t)return v;i=n.event&&k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!ic.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=fc.test(d)?d.replace(fc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+nc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=rc(mc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=tc(k,v,f)),u=uc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var vc=/%20/g,wc=/\[\]$/,xc=/\r?\n/g,yc=/^(?:submit|button|image|reset|file)$/i,zc=/^(?:input|select|textarea|keygen)/i;function Ac(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||wc.test(a)?d(a,e):Ac(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Ac(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Ac(c,a[c],b,e);return d.join("&").replace(vc,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&zc.test(this.nodeName)&&!yc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(xc,"\r\n")}}):{name:b.name,value:c.replace(xc,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Bc=0,Cc={},Dc={0:200,1223:204},Ec=n.ajaxSettings.xhr();a.attachEvent&&a.attachEvent("onunload",function(){for(var a in Cc)Cc[a]()}),k.cors=!!Ec&&"withCredentials"in Ec,k.ajax=Ec=!!Ec,n.ajaxTransport(function(a){var b;return k.cors||Ec&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Bc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Cc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Dc[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Cc[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),l.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Fc=[],Gc=/(=)\?(?=&|$)|\?\?/;n.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Fc.pop()||n.expando+"_"+cc++;return this[a]=!0,a}}),n.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Gc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Gc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=n.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Gc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||n.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Fc.push(e)),g&&n.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),n.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||l;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=n.buildFragment([a],b,e),e&&e.length&&n(e).remove(),n.merge([],d.childNodes))};var Hc=n.fn.load;n.fn.load=function(a,b,c){if("string"!=typeof a&&Hc)return Hc.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=n.trim(a.slice(h)),a=a.slice(0,h)),n.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&n.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?n("<div>").append(n.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},n.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){n.fn[b]=function(a){return this.on(b,a)}}),n.expr.filters.animated=function(a){return n.grep(n.timers,function(b){return a===b.elem}).length};var Ic=a.document.documentElement;function Jc(a){return n.isWindow(a)?a:9===a.nodeType&&a.defaultView}n.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=n.css(a,"position"),l=n(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=n.css(a,"top"),i=n.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),n.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},n.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){n.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,n.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Jc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===n.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),n.nodeName(a[0],"html")||(d=a.offset()),d.top+=n.css(a[0],"borderTopWidth",!0),d.left+=n.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-n.css(c,"marginTop",!0),left:b.left-d.left-n.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Ic;while(a&&!n.nodeName(a,"html")&&"static"===n.css(a,"position"))a=a.offsetParent;return a||Ic})}}),n.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;n.fn[b]=function(e){return J(this,function(b,e,f){var g=Jc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),n.each(["top","left"],function(a,b){n.cssHooks[b]=yb(k.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?n(a).position()[b]+"px":c):void 0})}),n.each({Height:"height",Width:"width"},function(a,b){n.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){n.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return n.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?n.css(b,c,g):n.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),n.fn.size=function(){return this.length},n.fn.andSelf=n.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return n});var Kc=a.jQuery,Lc=a.$;return n.noConflict=function(b){return a.$===n&&(a.$=Lc),b&&a.jQuery===n&&(a.jQuery=Kc),n},typeof b===U&&(a.jQuery=a.$=n),n});
Opal.mark_as_loaded(Opal.normalize_loadable_path("jquery"));
/* Generated by Opal 0.7.1 */
Opal.modules["game_of_life/version"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module;
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
Opal.cdecl($scope, 'VERSION', "0.0.1")
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["game_of_life/grid"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;
Opal.add_stubs(['$each_with_index', '$<<', '$apply', '$new', '$number_of_alive_neighbours_of', '$inject', '$+', '$to_s', '$inspect=', '$inspect', '$count', '$alive?', '$neighbours_of', '$out_of_bounds', '$-', '$[]', '$flatten', '$private', '$<', '$>=', '$length', '$first', '$build_dead']);
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
(function($base, $super) {
function $Grid(){};
var self = $Grid = $klass($base, $super, 'Grid', $Grid);
var def = self.$$proto, $scope = self.$$scope, TMP_10;
def.grid = nil;
def.$initialize = function(two_dimensional_array_of_cells) {
var self = this;
return self.grid = two_dimensional_array_of_cells;
};
def.$next = function() {
var $a, $b, TMP_1, self = this, new_grid = nil;
new_grid = [];
($a = ($b = self.grid).$each_with_index, $a.$$p = (TMP_1 = function(row, row_index){var self = TMP_1.$$s || this, $a, $b, TMP_2, new_row = nil;
if (row == null) row = nil;if (row_index == null) row_index = nil;
new_row = [];
($a = ($b = row).$each_with_index, $a.$$p = (TMP_2 = function(cell, column_index){var self = TMP_2.$$s || this;
if (cell == null) cell = nil;if (column_index == null) column_index = nil;
return new_row['$<<']($scope.get('Rules').$new(cell, self.$number_of_alive_neighbours_of(row_index, column_index)).$apply())}, TMP_2.$$s = self, TMP_2), $a).call($b);
return new_grid['$<<'](new_row);}, TMP_1.$$s = self, TMP_1), $a).call($b);
return $scope.get('Grid').$new(new_grid);
};
def.$to_s = function() {
var $a, $b, TMP_3, self = this;
return ($a = ($b = self.grid).$inject, $a.$$p = (TMP_3 = function(result, row){var self = TMP_3.$$s || this, $a, $b, TMP_4;
if (result == null) result = nil;if (row == null) row = nil;
result = ($a = ($b = row).$inject, $a.$$p = (TMP_4 = function(row_result, cell){var self = TMP_4.$$s || this;
if (row_result == null) row_result = nil;if (cell == null) cell = nil;
return row_result['$+'](cell.$to_s())}, TMP_4.$$s = self, TMP_4), $a).call($b, result);
return result['$+']("\n");}, TMP_3.$$s = self, TMP_3), $a).call($b, "");
};
def.$inspect = function() {
var $a, $b, TMP_5, self = this;
return ($a = ($b = self.grid).$inject, $a.$$p = (TMP_5 = function(result, row){var self = TMP_5.$$s || this, $a, $b, TMP_6;
if (result == null) result = nil;if (row == null) row = nil;
($a = ($b = row).$inject, $a.$$p = (TMP_6 = function(result, cell){var self = TMP_6.$$s || this, $a;
if (result == null) result = nil;if (cell == null) cell = nil;
return result = result['$+'](($a = cell, $a['$inspect=']($a.$inspect()['$+'](" "))))}, TMP_6.$$s = self, TMP_6), $a).call($b, result);
return result = result['$+']("\n");}, TMP_5.$$s = self, TMP_5), $a).call($b, "");
};
def.$number_of_alive_neighbours_of = function(row, column) {
var $a, $b, TMP_7, self = this;
return ($a = ($b = self.$neighbours_of(row, column)).$count, $a.$$p = (TMP_7 = function(cell){var self = TMP_7.$$s || this;
if (cell == null) cell = nil;
return cell['$alive?']()}, TMP_7.$$s = self, TMP_7), $a).call($b);
};
def.$iterate = TMP_10 = function() {
var $a, $b, TMP_8, self = this, $iter = TMP_10.$$p, $yield = $iter || nil;
TMP_10.$$p = null;
return ($a = ($b = self.grid).$each_with_index, $a.$$p = (TMP_8 = function(row, row_index){var self = TMP_8.$$s || this, $a, $b, TMP_9;
if (row == null) row = nil;if (row_index == null) row_index = nil;
return ($a = ($b = row).$each_with_index, $a.$$p = (TMP_9 = function(cell, column_index){var self = TMP_9.$$s || this, $a;
if (cell == null) cell = nil;if (column_index == null) column_index = nil;
return $a = Opal.yieldX($yield, [cell, row_index, column_index]), $a === $breaker ? $a : $a}, TMP_9.$$s = self, TMP_9), $a).call($b)}, TMP_8.$$s = self, TMP_8), $a).call($b);
};
def.$neighbours_of = function(row, column) {
var $a, self = this;
return [((($a = self.$out_of_bounds(row['$-'](1), column)) !== false && $a !== nil) ? $a : self.grid['$[]'](row['$-'](1))['$[]'](column)), ((($a = self.$out_of_bounds(row['$-'](1), column['$+'](1))) !== false && $a !== nil) ? $a : self.grid['$[]'](row['$-'](1))['$[]'](column['$+'](1))), ((($a = self.$out_of_bounds(row, column['$+'](1))) !== false && $a !== nil) ? $a : self.grid['$[]'](row)['$[]'](column['$+'](1))), ((($a = self.$out_of_bounds(row['$+'](1), column['$+'](1))) !== false && $a !== nil) ? $a : self.grid['$[]'](row['$+'](1))['$[]'](column['$+'](1))), ((($a = self.$out_of_bounds(row['$+'](1), column)) !== false && $a !== nil) ? $a : self.grid['$[]'](row['$+'](1))['$[]'](column)), ((($a = self.$out_of_bounds(row['$+'](1), column['$-'](1))) !== false && $a !== nil) ? $a : self.grid['$[]'](row['$+'](1))['$[]'](column['$-'](1))), ((($a = self.$out_of_bounds(row, column['$-'](1))) !== false && $a !== nil) ? $a : self.grid['$[]'](row)['$[]'](column['$-'](1))), ((($a = self.$out_of_bounds(row['$-'](1), column['$-'](1))) !== false && $a !== nil) ? $a : self.grid['$[]'](row['$-'](1))['$[]'](column['$-'](1)))];
};
def.$all_cells = function() {
var self = this;
return self.grid.$flatten();
};
self.$private();
return (def.$out_of_bounds = function(row, column) {
var $a, $b, $c, $d, self = this;
if ((($a = ((($b = ((($c = ((($d = (row['$<'](0))) !== false && $d !== nil) ? $d : (row['$>='](self.grid.$length())))) !== false && $c !== nil) ? $c : (column['$<'](0)))) !== false && $b !== nil) ? $b : (column['$>='](self.grid.$first().$length())))) !== nil && (!$a.$$is_boolean || $a == true))) {
return $scope.get('Cell').$build_dead()
} else {
return nil
};
}, nil) && 'out_of_bounds';
})(self, null)
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["game_of_life/cell"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;
Opal.add_stubs(['$new', '$==', '$build_alive', '$build_dead', '$alive?', '$to_s', '$object_id']);
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
(function($base, $super) {
function $Cell(){};
var self = $Cell = $klass($base, $super, 'Cell', $Cell);
var def = self.$$proto, $scope = self.$$scope;
def.alive = nil;
Opal.cdecl($scope, 'ALIVE', $scope.get('Object').$new());
Opal.cdecl($scope, 'DEAD', $scope.get('Object').$new());
Opal.defs(self, '$build_alive', function() {
var self = this;
return self.$new($scope.get('ALIVE'));
});
Opal.defs(self, '$build_dead', function() {
var self = this;
return self.$new($scope.get('DEAD'));
});
def.$initialize = function(alive) {
var self = this;
return self.alive = alive;
};
def['$dead?'] = function() {
var self = this;
return self.alive['$==']($scope.get('DEAD'));
};
def['$alive?'] = function() {
var self = this;
return self.alive['$==']($scope.get('ALIVE'));
};
def.$live = function() {
var self = this;
return $scope.get('Cell').$build_alive();
};
def.$die = function() {
var self = this;
return $scope.get('Cell').$build_dead();
};
def.$to_s = function() {
var self = this;
if (self.alive['$==']($scope.get('ALIVE'))) {
return "*"
} else {
return " "
};
};
return (def.$inspect = function() {
var $a, self = this;
return "" + (((function() {if ((($a = self['$alive?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
return "A"
} else {
return "D"
}; return nil; })())) + (self.$object_id().$to_s());
}, nil) && 'inspect';
})(self, null)
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["game_of_life/rules"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;
Opal.add_stubs(['$alive?', '$<', '$die', '$>', '$==', '$live', '$dead?']);
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
(function($base, $super) {
function $Rules(){};
var self = $Rules = $klass($base, $super, 'Rules', $Rules);
var def = self.$$proto, $scope = self.$$scope;
def.cell = def.alive_count = nil;
def.$initialize = function(cell, alive_neighbour_count) {
var self = this;
self.cell = cell;
return self.alive_count = alive_neighbour_count;
};
return (def.$apply = function() {
var $a, $b, $c, self = this;
return (function() {if ((($a = ($b = self.cell['$alive?'](), $b !== false && $b !== nil ?self.alive_count['$<'](2) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {return self.cell.$die()}else if ((($a = ($b = self.cell['$alive?'](), $b !== false && $b !== nil ?self.alive_count['$>'](3) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {return self.cell.$die()}else if ((($a = ($b = self.cell['$alive?'](), $b !== false && $b !== nil ?(((($c = self.alive_count['$=='](2)) !== false && $c !== nil) ? $c : self.alive_count['$=='](3))) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {return self.cell.$live()}else if ((($a = ($b = self.cell['$dead?'](), $b !== false && $b !== nil ?self.alive_count['$=='](3) : $b)) !== nil && (!$a.$$is_boolean || $a == true))) {return self.cell.$live()}else {return self.cell}})();
}, nil) && 'apply';
})(self, null)
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["game_of_life/parser"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;
Opal.add_stubs(['$build_cells', '$new', '$private', '$tap', '$map', '$<<', '$==', '$split']);
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
(function($base, $super) {
function $Parser(){};
var self = $Parser = $klass($base, $super, 'Parser', $Parser);
var def = self.$$proto, $scope = self.$$scope;
def.cells = nil;
def.$initialize = function(input) {
var self = this;
return self.cells = self.$build_cells(input);
};
def.$parse = function() {
var self = this;
return $scope.get('Grid').$new(self.cells);
};
self.$private();
return (def.$build_cells = function(input) {
var $a, $b, TMP_1, self = this;
return ($a = ($b = []).$tap, $a.$$p = (TMP_1 = function(result){var self = TMP_1.$$s || this, $a, $b, TMP_2;
if (result == null) result = nil;
return ($a = ($b = input.$split("\n")).$map, $a.$$p = (TMP_2 = function(line){var self = TMP_2.$$s || this, $a, $b, TMP_3;
if (line == null) line = nil;
return result['$<<'](($a = ($b = line.$split(/^/)).$map, $a.$$p = (TMP_3 = function(symbol){var self = TMP_3.$$s || this;
if (symbol == null) symbol = nil;
if (symbol['$==']("*")) {
return $scope.get('Cell').$new((($scope.get('Cell')).$$scope.get('ALIVE')))
} else {
return $scope.get('Cell').$new((($scope.get('Cell')).$$scope.get('DEAD')))
}}, TMP_3.$$s = self, TMP_3), $a).call($b))}, TMP_2.$$s = self, TMP_2), $a).call($b)}, TMP_1.$$s = self, TMP_1), $a).call($b);
}, nil) && 'build_cells';
})(self, null)
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["game_of_life/view"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;
Opal.add_stubs(['$parse', '$next', '$iterate', '$alive?']);
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
(function($base, $super) {
function $View(){};
var self = $View = $klass($base, $super, 'View', $View);
var def = self.$$proto, $scope = self.$$scope;
def.generation = nil;
Opal.cdecl($scope, 'ALIVE_STYLE', "alive");
Opal.cdecl($scope, 'DEAD_STYLE', "dead");
def.$initialize = function(table_element, start_element, stop_element) {
var self = this;
self.element = table_element;
self.start_element = start_element;
self.stop_element = stop_element;
self.generation_count = 0;
return self.$parse();
};
def.$parse = function() {
var self = this;
var grid = [];
var rowElements = this.element.find('tr');
rowElements.each(function(rowIndex){
var rowElement = $(this);
var cells = rowElement.find('td');
var row = []
cells.each(function(columnIndex){
var cellElement = $(this);
cellElement.addClass("row_" + rowIndex).addClass("column_" + columnIndex);
var cell = cellElement.hasClass("alive") ? Opal.GameOfLife.Cell.$build_alive() : Opal.GameOfLife.Cell.$build_dead();
row.push(cell);
});
grid.push(row);
});
this.generation = Opal.GameOfLife.Grid.$new(grid);
};
def.$next = function() {
var $a, $b, TMP_1, self = this;
self.generation = self.generation.$next();
return ($a = ($b = self.generation).$iterate, $a.$$p = (TMP_1 = function(cell, row_index, column_index){var self = TMP_1.$$s || this, $a, row_matcher = nil, column_matcher = nil, cell_matcher = nil, cell_style = nil;
if (cell == null) cell = nil;if (row_index == null) row_index = nil;if (column_index == null) column_index = nil;
row_matcher = ".row_" + (row_index);
column_matcher = ".column_" + (column_index);
cell_matcher = "" + (row_matcher) + (column_matcher);
cell_style = (function() {if ((($a = cell['$alive?']()) !== nil && (!$a.$$is_boolean || $a == true))) {
return $scope.get('ALIVE_STYLE')
} else {
return $scope.get('DEAD_STYLE')
}; return nil; })();
var cellElement = $(cell_matcher, this.element);
cellElement.removeClass($scope.get('ALIVE_STYLE'));
cellElement.removeClass($scope.get('DEAD_STYLE'));
cellElement.addClass(cell_style);
}, TMP_1.$$s = self, TMP_1), $a).call($b);
};
return (def.$render = function() {
var self = this;
var intervalId = null;
this.start_element.click(
function(){
intervalId = setInterval(
function(){
console.log("Generation " + self.generation_count);
self.$next();
self.generation_count++;
},
1000);
}
);
this.stop_element.click(
function(){
if(intervalId != null) {
clearInterval(intervalId);
intervalId = null;
}
}
);
}, nil) && 'render';
})(self, null)
})(self)
};
/* Generated by Opal 0.7.1 */
Opal.modules["game_of_life/application"] = function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass;
Opal.add_stubs(['$to_i', '$parse', '$new', '$times', '$puts', '$next', '$render']);
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
(function($base, $super) {
function $ConsoleApplication(){};
var self = $ConsoleApplication = $klass($base, $super, 'ConsoleApplication', $ConsoleApplication);
var def = self.$$proto, $scope = self.$$scope;
def.input = def.iterations = nil;
def.$initialize = function(input, iterations) {
var self = this;
if (iterations == null) {
iterations = 5
}
self.input = input;
return self.iterations = iterations.$to_i();
};
return (def.$run = function() {
var $a, $b, TMP_1, self = this, generation = nil;
generation = $scope.get('Parser').$new(self.input).$parse();
return ($a = ($b = self.iterations).$times, $a.$$p = (TMP_1 = function(){var self = TMP_1.$$s || this;
self.$puts(generation);
self.$puts("---");
return generation = generation.$next();}, TMP_1.$$s = self, TMP_1), $a).call($b);
}, nil) && 'run';
})(self, null);
(function($base, $super) {
function $BrowserApplication(){};
var self = $BrowserApplication = $klass($base, $super, 'BrowserApplication', $BrowserApplication);
var def = self.$$proto, $scope = self.$$scope;
def.view = nil;
def.$initialize = function(view_element, start_element, stop_element) {
var self = this;
self.$puts("Game Of Life " + ((($scope.get('GameOfLife')).$$scope.get('VERSION'))));
return self.view = $scope.get('View').$new(view_element, start_element, stop_element);
};
return (def.$run = function() {
var self = this;
return self.view.$render();
}, nil) && 'run';
})(self, null);
})(self)
};
/* Generated by Opal 0.7.1 */
(function(Opal) {
Opal.dynamic_require_severity = "error";
var self = Opal.top, $scope = Opal, nil = Opal.nil, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module;
Opal.add_stubs(['$require']);
self.$require("opal");
self.$require("jquery");
self.$require("game_of_life/version");
self.$require("game_of_life/grid");
self.$require("game_of_life/cell");
self.$require("game_of_life/rules");
self.$require("game_of_life/parser");
self.$require("game_of_life/view");
self.$require("game_of_life/application");
return (function($base) {
var self = $module($base, 'GameOfLife');
var def = self.$$proto, $scope = self.$$scope;
nil
})(self);
})(Opal);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment