(function(undefined) { // @note // A few conventions for the documentation of this file: // 1. Always use "//" (in contrast with "/**/") // 2. The syntax used is Yardoc (yardoc.org), which is intended for Ruby (se below) // 3. `@param` and `@return` types should be preceded by `JS.` when referring to // JavaScript constructors (e.g. `JS.Function`) otherwise Ruby is assumed. // 4. `nil` and `null` being unambiguous refer to the respective // objects/values in Ruby and JavaScript // 5. This is still WIP :) so please give feedback and suggestions on how // to improve or for alternative solutions // // The way the code is digested before going through Yardoc is a secret kept // in the docs repo (https://github.com/opal/docs/tree/master). var global_object = this, console; // Detect the global object if (typeof(global) !== 'undefined') { global_object = global; } if (typeof(window) !== 'undefined') { global_object = window; } // Setup a dummy console object if missing if (typeof(global_object.console) === 'object') { console = global_object.console; } else if (global_object.console == null) { console = global_object.console = {}; } else { console = {}; } if (!('log' in console)) { console.log = function () {}; } if (!('warn' in console)) { console.warn = console.log; } if (typeof(this.Opal) !== 'undefined') { console.warn('Opal already loaded. Loading twice can cause troubles, please fix your setup.'); return this.Opal; } var nil; // The actual class for BasicObject var BasicObject; // The actual Object class. // The leading underscore is to avoid confusion with window.Object() var _Object; // The actual Module class var Module; // The actual Class class var Class; // The Opal object that is exposed globally var Opal = this.Opal = {}; // This is a useful reference to global object inside ruby files Opal.global = global_object; global_object.Opal = Opal; // Configure runtime behavior with regards to require and unsupported fearures Opal.config = { missing_require_severity: 'error', // error, warning, ignore unsupported_features_severity: 'warning', // error, warning, ignore enable_stack_trace: true // true, false }; // Minify common function calls var $hasOwn = Object.hasOwnProperty; var $bind = Function.prototype.bind; var $setPrototype = Object.setPrototypeOf; var $slice = Array.prototype.slice; var $splice = Array.prototype.splice; // Nil object id is always 4 var nil_id = 4; // Generates even sequential numbers greater than 4 // (nil_id) to serve as unique ids for ruby objects var unique_id = nil_id; // Return next unique id Opal.uid = function() { unique_id += 2; return unique_id; }; // Retrieve or assign the id of an object Opal.id = function(obj) { if (obj.$$is_number) return (obj * 2)+1; if (obj.$$id != null) { return obj.$$id; } $defineProperty(obj, '$$id', Opal.uid()); return obj.$$id; }; // Globals table Opal.gvars = {}; // Exit function, this should be replaced by platform specific implementation // (See nodejs and chrome for examples) Opal.exit = function(status) { if (Opal.gvars.DEBUG) console.log('Exited with status '+status); }; // keeps track of exceptions for $! Opal.exceptions = []; // @private // Pops an exception from the stack and updates `$!`. Opal.pop_exception = function() { Opal.gvars["!"] = Opal.exceptions.pop() || nil; }; // Inspect any kind of object, including non Ruby ones Opal.inspect = function(obj) { if (obj === undefined) { return "undefined"; } else if (obj === null) { return "null"; } else if (!obj.$$class) { return obj.toString(); } else { return obj.$inspect(); } }; function $defineProperty(object, name, initialValue) { if (typeof(object) === "string") { // Special case for: // s = "string" // def s.m; end // String class is the only class that: // + compiles to JS primitive // + allows method definition directly on instances // numbers, true, false and nil do not support it. object[name] = initialValue; } else { Object.defineProperty(object, name, { value: initialValue, enumerable: false, configurable: true, writable: true }); } } Opal.defineProperty = $defineProperty; Opal.slice = $slice; // Truth // ----- Opal.truthy = function(val) { return (val !== nil && val != null && (!val.$$is_boolean || val == true)); }; Opal.falsy = function(val) { return (val === nil || val == null || (val.$$is_boolean && val == false)) }; // Constants // --------- // // For future reference: // - The Rails autoloading guide (http://guides.rubyonrails.org/v5.0/autoloading_and_reloading_constants.html) // - @ConradIrwin's 2012 post on “Everything you ever wanted to know about constant lookup in Ruby” (http://cirw.in/blog/constant-lookup.html) // // Legend of MRI concepts/names: // - constant reference (cref): the module/class that acts as a namespace // - nesting: the namespaces wrapping the current scope, e.g. nesting inside // `module A; module B::C; end; end` is `[B::C, A]` // Get the constant in the scope of the current cref function const_get_name(cref, name) { if (cref) return cref.$$const[name]; } // Walk up the nesting array looking for the constant function const_lookup_nesting(nesting, name) { var i, ii, result, constant; if (nesting.length === 0) return; // If the nesting is not empty the constant is looked up in its elements // and in order. The ancestors of those elements are ignored. for (i = 0, ii = nesting.length; i < ii; i++) { constant = nesting[i].$$const[name]; if (constant != null) return constant; } } // Walk up the ancestors chain looking for the constant function const_lookup_ancestors(cref, name) { var i, ii, result, ancestors; if (cref == null) return; ancestors = Opal.ancestors(cref); for (i = 0, ii = ancestors.length; i < ii; i++) { if (ancestors[i].$$const && $hasOwn.call(ancestors[i].$$const, name)) { return ancestors[i].$$const[name]; } } } // Walk up Object's ancestors chain looking for the constant, // but only if cref is missing or a module. function const_lookup_Object(cref, name) { if (cref == null || cref.$$is_module) { return const_lookup_ancestors(_Object, name); } } // Call const_missing if nothing else worked function const_missing(cref, name, skip_missing) { if (!skip_missing) { return (cref || _Object).$const_missing(name); } } // Look for the constant just in the current cref or call `#const_missing` Opal.const_get_local = function(cref, name, skip_missing) { var result; if (cref == null) return; if (cref === '::') cref = _Object; if (!cref.$$is_module && !cref.$$is_class) { throw new Opal.TypeError(cref.toString() + " is not a class/module"); } result = const_get_name(cref, name); if (result != null) return result; result = const_missing(cref, name, skip_missing); if (result != null) return result; }; // Look for the constant relative to a cref or call `#const_missing` (when the // constant is prefixed by `::`). Opal.const_get_qualified = function(cref, name, skip_missing) { var result, cache, cached, current_version = Opal.const_cache_version; if (cref == null) return; if (cref === '::') cref = _Object; if (!cref.$$is_module && !cref.$$is_class) { throw new Opal.TypeError(cref.toString() + " is not a class/module"); } if ((cache = cref.$$const_cache) == null) { $defineProperty(cref, '$$const_cache', Object.create(null)); cache = cref.$$const_cache; } cached = cache[name]; if (cached == null || cached[0] !== current_version) { ((result = const_get_name(cref, name)) != null) || ((result = const_lookup_ancestors(cref, name)) != null); cache[name] = [current_version, result]; } else { result = cached[1]; } return result != null ? result : const_missing(cref, name, skip_missing); }; // Initialize the top level constant cache generation counter Opal.const_cache_version = 1; // Look for the constant in the open using the current nesting and the nearest // cref ancestors or call `#const_missing` (when the constant has no :: prefix). Opal.const_get_relative = function(nesting, name, skip_missing) { var cref = nesting[0], result, current_version = Opal.const_cache_version, cache, cached; if ((cache = nesting.$$const_cache) == null) { $defineProperty(nesting, '$$const_cache', Object.create(null)); cache = nesting.$$const_cache; } cached = cache[name]; if (cached == null || cached[0] !== current_version) { ((result = const_get_name(cref, name)) != null) || ((result = const_lookup_nesting(nesting, name)) != null) || ((result = const_lookup_ancestors(cref, name)) != null) || ((result = const_lookup_Object(cref, name)) != null); cache[name] = [current_version, result]; } else { result = cached[1]; } return result != null ? result : const_missing(cref, name, skip_missing); }; // Register the constant on a cref and opportunistically set the name of // unnamed classes/modules. Opal.const_set = function(cref, name, value) { if (cref == null || cref === '::') cref = _Object; if (value.$$is_a_module) { if (value.$$name == null || value.$$name === nil) value.$$name = name; if (value.$$base_module == null) value.$$base_module = cref; } cref.$$const = (cref.$$const || Object.create(null)); cref.$$const[name] = value; // Add a short helper to navigate constants manually. // @example // Opal.$$.Regexp.$$.IGNORECASE cref.$$ = cref.$$const; Opal.const_cache_version++; // Expose top level constants onto the Opal object if (cref === _Object) Opal[name] = value; // Name new class directly onto current scope (Opal.Foo.Baz = klass) $defineProperty(cref, name, value); return value; }; // Get all the constants reachable from a given cref, by default will include // inherited constants. Opal.constants = function(cref, inherit) { if (inherit == null) inherit = true; var module, modules = [cref], module_constants, i, ii, constants = {}, constant; if (inherit) modules = modules.concat(Opal.ancestors(cref)); if (inherit && cref.$$is_module) modules = modules.concat([Opal.Object]).concat(Opal.ancestors(Opal.Object)); for (i = 0, ii = modules.length; i < ii; i++) { module = modules[i]; // Don not show Objects constants unless we're querying Object itself if (cref !== _Object && module == _Object) break; for (constant in module.$$const) { constants[constant] = true; } } return Object.keys(constants); }; // Remove a constant from a cref. Opal.const_remove = function(cref, name) { Opal.const_cache_version++; if (cref.$$const[name] != null) { var old = cref.$$const[name]; delete cref.$$const[name]; return old; } if (cref.$$autoload != null && cref.$$autoload[name] != null) { delete cref.$$autoload[name]; return nil; } throw Opal.NameError.$new("constant "+cref+"::"+cref.$name()+" not defined"); }; // Modules & Classes // ----------------- // 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, `superclass` 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 `scope` 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 `scope` is an object (not a class/module), we simple get its class and // use that as the scope instead. // // @param scope [Object] where the class is being created // @param superclass [Class,null] superclass of the new class (may be null) // @param id [String] the name of the class to be created // @param constructor [JS.Function] function to use as constructor // // @return new [Class] or existing ruby class // Opal.allocate_class = function(name, superclass) { var klass, constructor; if (superclass != null && superclass.$$bridge) { // Inheritance from bridged classes requires // calling original JS constructors constructor = function() { var args = $slice.call(arguments), self = new ($bind.apply(superclass.$$constructor, [null].concat(args)))(); // and replacing a __proto__ manually $setPrototype(self, klass.$$prototype); return self; } } else { constructor = function(){}; } if (name) { $defineProperty(constructor, 'displayName', '::'+name); } klass = constructor; $defineProperty(klass, '$$name', name); $defineProperty(klass, '$$constructor', constructor); $defineProperty(klass, '$$prototype', constructor.prototype); $defineProperty(klass, '$$const', {}); $defineProperty(klass, '$$is_class', true); $defineProperty(klass, '$$is_a_module', true); $defineProperty(klass, '$$super', superclass); $defineProperty(klass, '$$cvars', {}); $defineProperty(klass, '$$own_included_modules', []); $defineProperty(klass, '$$own_prepended_modules', []); $defineProperty(klass, '$$ancestors', []); $defineProperty(klass, '$$ancestors_cache_version', null); $defineProperty(klass.$$prototype, '$$class', klass); // By default if there are no singleton class methods // __proto__ is Class.prototype // Later singleton methods generate a singleton_class // and inject it into ancestors chain if (Opal.Class) { $setPrototype(klass, Opal.Class.prototype); } if (superclass != null) { $setPrototype(klass.$$prototype, superclass.$$prototype); if (superclass.$$meta) { // If superclass has metaclass then we have explicitely inherit it. Opal.build_class_singleton_class(klass); } } return klass; }; function find_existing_class(scope, name) { // Try to find the class in the current scope var klass = const_get_name(scope, name); // If the class exists in the scope, then we must use that if (klass) { // Make sure the existing constant is a class, or raise error if (!klass.$$is_class) { throw Opal.TypeError.$new(name + " is not a class"); } return klass; } } function ensureSuperclassMatch(klass, superclass) { if (klass.$$super !== superclass) { throw Opal.TypeError.$new("superclass mismatch for class " + klass.$$name); } } Opal.klass = function(scope, superclass, name) { var bridged; if (scope == null) { // Global scope scope = _Object; } else if (!scope.$$is_class && !scope.$$is_module) { // Scope is an object, use its class scope = scope.$$class; } // If the superclass is not an Opal-generated class then we're bridging a native JS class if (superclass != null && !superclass.hasOwnProperty('$$is_class')) { bridged = superclass; superclass = _Object; } var klass = find_existing_class(scope, name); if (klass) { if (superclass) { // Make sure existing class has same superclass ensureSuperclassMatch(klass, superclass); } return klass; } // Class doesn't exist, create a new one with given superclass... // Not specifying a superclass means we can assume it to be Object if (superclass == null) { superclass = _Object; } // Create the class object (instance of Class) klass = Opal.allocate_class(name, superclass); Opal.const_set(scope, name, klass); // Call .inherited() hook with new class on the superclass if (superclass.$inherited) { superclass.$inherited(klass); } if (bridged) { Opal.bridge(bridged, klass); } return klass; }; // Define new module (or return existing module). The given `scope` 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 scope is a ruby // object then that objects real ruby class is used (e.g. if the scope is the // main object, then the top level `Object` class is used as the scope). // // If a module of the given name is already defined in the scope, then that // instance is just returned. // // If there is a class of the given name in the scope, then an error is // generated instead (cannot have a class and module of same name in same scope). // // Otherwise, a new module is created in the scope with the given name, and that // new instance is returned back (to be referenced at runtime). // // @param scope [Module, Class] class or module this definition is inside // @param id [String] the name of the new (or existing) module // // @return [Module] Opal.allocate_module = function(name) { var constructor = function(){}; if (name) { $defineProperty(constructor, 'displayName', name+'.$$constructor'); } var module = constructor; if (name) $defineProperty(constructor, 'displayName', name+'.constructor'); $defineProperty(module, '$$name', name); $defineProperty(module, '$$prototype', constructor.prototype); $defineProperty(module, '$$const', {}); $defineProperty(module, '$$is_module', true); $defineProperty(module, '$$is_a_module', true); $defineProperty(module, '$$cvars', {}); $defineProperty(module, '$$iclasses', []); $defineProperty(module, '$$own_included_modules', []); $defineProperty(module, '$$own_prepended_modules', []); $defineProperty(module, '$$ancestors', [module]); $defineProperty(module, '$$ancestors_cache_version', null); $setPrototype(module, Opal.Module.prototype); return module; }; function find_existing_module(scope, name) { var module = const_get_name(scope, name); if (module == null && scope === _Object) module = const_lookup_ancestors(_Object, name); if (module) { if (!module.$$is_module && module !== _Object) { throw Opal.TypeError.$new(name + " is not a module"); } } return module; } Opal.module = function(scope, name) { var module; if (scope == null) { // Global scope scope = _Object; } else if (!scope.$$is_class && !scope.$$is_module) { // Scope is an object, use its class scope = scope.$$class; } module = find_existing_module(scope, name); if (module) { return module; } // Module doesnt exist, create a new one... module = Opal.allocate_module(name); Opal.const_set(scope, name, module); 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 object [Object] the ruby object // @return [Class] the singleton class for object Opal.get_singleton_class = function(object) { if (object.$$meta) { return object.$$meta; } if (object.hasOwnProperty('$$is_class')) { return Opal.build_class_singleton_class(object); } else if (object.hasOwnProperty('$$is_module')) { return Opal.build_module_singletin_class(object); } else { return Opal.build_object_singleton_class(object); } }; // Build the singleton class for an existing class. Class object are built // with their singleton class already in the prototype chain and inheriting // from their superclass object (up to `Class` itself). // // NOTE: Actually in MRI a class' singleton class inherits from its // superclass' singleton class which in turn inherits from Class. // // @param klass [Class] // @return [Class] Opal.build_class_singleton_class = function(klass) { var superclass, meta; if (klass.$$meta) { return klass.$$meta; } // The singleton_class superclass is the singleton_class of its superclass; // but BasicObject has no superclass (its `$$super` is null), thus we // fallback on `Class`. superclass = klass === BasicObject ? Class : Opal.get_singleton_class(klass.$$super); meta = Opal.allocate_class(null, superclass, function(){}); $defineProperty(meta, '$$is_singleton', true); $defineProperty(meta, '$$singleton_of', klass); $defineProperty(klass, '$$meta', meta); $setPrototype(klass, meta.$$prototype); // Restoring ClassName.class $defineProperty(klass, '$$class', Opal.Class); return meta; }; Opal.build_module_singletin_class = function(mod) { if (mod.$$meta) { return mod.$$meta; } var meta = Opal.allocate_class(null, Opal.Module, function(){}); $defineProperty(meta, '$$is_singleton', true); $defineProperty(meta, '$$singleton_of', mod); $defineProperty(mod, '$$meta', meta); $setPrototype(mod, meta.$$prototype); // Restoring ModuleName.class $defineProperty(mod, '$$class', Opal.Module); return meta; }; // Build the singleton class for a Ruby (non class) Object. // // @param object [Object] // @return [Class] Opal.build_object_singleton_class = function(object) { var superclass = object.$$class, klass = Opal.allocate_class(nil, superclass, function(){}); $defineProperty(klass, '$$is_singleton', true); $defineProperty(klass, '$$singleton_of', object); delete klass.$$prototype.$$class; $defineProperty(object, '$$meta', klass); $setPrototype(object, object.$$meta.$$prototype); return klass; }; Opal.is_method = function(prop) { return (prop[0] === '$' && prop[1] !== '$'); }; Opal.instance_methods = function(mod) { var exclude = [], results = [], ancestors = Opal.ancestors(mod); for (var i = 0, l = ancestors.length; i < l; i++) { var ancestor = ancestors[i], proto = ancestor.$$prototype; if (proto.hasOwnProperty('$$dummy')) { proto = proto.$$define_methods_on; } var props = Object.getOwnPropertyNames(proto); for (var j = 0, ll = props.length; j < ll; j++) { var prop = props[j]; if (Opal.is_method(prop)) { var method_name = prop.slice(1), method = proto[prop]; if (method.$$stub && exclude.indexOf(method_name) === -1) { exclude.push(method_name); } if (!method.$$stub && results.indexOf(method_name) === -1 && exclude.indexOf(method_name) === -1) { results.push(method_name); } } } } return results; }; Opal.own_instance_methods = function(mod) { var results = [], proto = mod.$$prototype; if (proto.hasOwnProperty('$$dummy')) { proto = proto.$$define_methods_on; } var props = Object.getOwnPropertyNames(proto); for (var i = 0, length = props.length; i < length; i++) { var prop = props[i]; if (Opal.is_method(prop)) { var method = proto[prop]; if (!method.$$stub) { var method_name = prop.slice(1); results.push(method_name); } } } return results; }; Opal.methods = function(obj) { return Opal.instance_methods(Opal.get_singleton_class(obj)); }; Opal.own_methods = function(obj) { return Opal.own_instance_methods(Opal.get_singleton_class(obj)); }; Opal.receiver_methods = function(obj) { var mod = Opal.get_singleton_class(obj); var singleton_methods = Opal.own_instance_methods(mod); var instance_methods = Opal.own_instance_methods(mod.$$super); return singleton_methods.concat(instance_methods); }; // Returns an object containing all pairs of names/values // for all class variables defined in provided +module+ // and its ancestors. // // @param module [Module] // @return [Object] Opal.class_variables = function(module) { var ancestors = Opal.ancestors(module), i, length = ancestors.length, result = {}; for (i = length - 1; i >= 0; i--) { var ancestor = ancestors[i]; for (var cvar in ancestor.$$cvars) { result[cvar] = ancestor.$$cvars[cvar]; } } return result; }; // Sets class variable with specified +name+ to +value+ // in provided +module+ // // @param module [Module] // @param name [String] // @param value [Object] Opal.class_variable_set = function(module, name, value) { var ancestors = Opal.ancestors(module), i, length = ancestors.length; for (i = length - 2; i >= 0; i--) { var ancestor = ancestors[i]; if ($hasOwn.call(ancestor.$$cvars, name)) { ancestor.$$cvars[name] = value; return value; } } module.$$cvars[name] = value; return value; }; function isRoot(proto) { return proto.hasOwnProperty('$$iclass') && proto.hasOwnProperty('$$root'); } function own_included_modules(module) { var result = [], mod, proto = Object.getPrototypeOf(module.$$prototype); while (proto) { if (proto.hasOwnProperty('$$class')) { // superclass break; } mod = protoToModule(proto); if (mod) { result.push(mod); } proto = Object.getPrototypeOf(proto); } return result; } function own_prepended_modules(module) { var result = [], mod, proto = Object.getPrototypeOf(module.$$prototype); if (module.$$prototype.hasOwnProperty('$$dummy')) { while (proto) { if (proto === module.$$prototype.$$define_methods_on) { break; } mod = protoToModule(proto); if (mod) { result.push(mod); } proto = Object.getPrototypeOf(proto); } } return result; } // 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 module [Module] the module to include // @param includer [Module] the target class to include module into // @return [null] Opal.append_features = function(module, includer) { var module_ancestors = Opal.ancestors(module); var iclasses = []; if (module_ancestors.indexOf(includer) !== -1) { throw Opal.ArgumentError.$new('cyclic include detected'); } for (var i = 0, length = module_ancestors.length; i < length; i++) { var ancestor = module_ancestors[i], iclass = create_iclass(ancestor); $defineProperty(iclass, '$$included', true); iclasses.push(iclass); } var includer_ancestors = Opal.ancestors(includer), chain = chain_iclasses(iclasses), start_chain_after, end_chain_on; if (includer_ancestors.indexOf(module) === -1) { // first time include // includer -> chain.first -> ...chain... -> chain.last -> includer.parent start_chain_after = includer.$$prototype; end_chain_on = Object.getPrototypeOf(includer.$$prototype); } else { // The module has been already included, // we don't need to put it into the ancestors chain again, // but this module may have new included modules. // If it's true we need to copy them. // // The simplest way is to replace ancestors chain from // parent // | // `module` iclass (has a $$root flag) // | // ...previos chain of module.included_modules ... // | // "next ancestor" (has a $$root flag or is a real class) // // to // parent // | // `module` iclass (has a $$root flag) // | // ...regenerated chain of module.included_modules // | // "next ancestor" (has a $$root flag or is a real class) // // because there are no intermediate classes between `parent` and `next ancestor`. // It doesn't break any prototypes of other objects as we don't change class references. var proto = includer.$$prototype, parent = proto, module_iclass = Object.getPrototypeOf(parent); while (module_iclass != null) { if (isRoot(module_iclass) && module_iclass.$$module === module) { break; } parent = module_iclass; module_iclass = Object.getPrototypeOf(module_iclass); } var next_ancestor = Object.getPrototypeOf(module_iclass); // skip non-root iclasses (that were recursively included) while (next_ancestor.hasOwnProperty('$$iclass') && !isRoot(next_ancestor)) { next_ancestor = Object.getPrototypeOf(next_ancestor); } start_chain_after = parent; end_chain_on = next_ancestor; } $setPrototype(start_chain_after, chain.first); $setPrototype(chain.last, end_chain_on); // recalculate own_included_modules cache includer.$$own_included_modules = own_included_modules(includer); Opal.const_cache_version++; }; Opal.prepend_features = function(module, prepender) { // Here we change the ancestors chain from // // prepender // | // parent // // to: // // dummy(prepender) // | // iclass(module) // | // iclass(prepender) // | // parent var module_ancestors = Opal.ancestors(module); var iclasses = []; if (module_ancestors.indexOf(prepender) !== -1) { throw Opal.ArgumentError.$new('cyclic prepend detected'); } for (var i = 0, length = module_ancestors.length; i < length; i++) { var ancestor = module_ancestors[i], iclass = create_iclass(ancestor); $defineProperty(iclass, '$$prepended', true); iclasses.push(iclass); } var chain = chain_iclasses(iclasses), dummy_prepender = prepender.$$prototype, previous_parent = Object.getPrototypeOf(dummy_prepender), prepender_iclass, start_chain_after, end_chain_on; if (dummy_prepender.hasOwnProperty('$$dummy')) { // The module already has some prepended modules // which means that we don't need to make it "dummy" prepender_iclass = dummy_prepender.$$define_methods_on; } else { // Making the module "dummy" prepender_iclass = create_dummy_iclass(prepender); flush_methods_in(prepender); $defineProperty(dummy_prepender, '$$dummy', true); $defineProperty(dummy_prepender, '$$define_methods_on', prepender_iclass); // Converting // dummy(prepender) -> previous_parent // to // dummy(prepender) -> iclass(prepender) -> previous_parent $setPrototype(dummy_prepender, prepender_iclass); $setPrototype(prepender_iclass, previous_parent); } var prepender_ancestors = Opal.ancestors(prepender); if (prepender_ancestors.indexOf(module) === -1) { // first time prepend start_chain_after = dummy_prepender; // next $$root or prepender_iclass or non-$$iclass end_chain_on = Object.getPrototypeOf(dummy_prepender); while (end_chain_on != null) { if ( end_chain_on.hasOwnProperty('$$root') || end_chain_on === prepender_iclass || !end_chain_on.hasOwnProperty('$$iclass') ) { break; } end_chain_on = Object.getPrototypeOf(end_chain_on); } } else { throw Opal.RuntimeError.$new("Prepending a module multiple times is not supported"); } $setPrototype(start_chain_after, chain.first); $setPrototype(chain.last, end_chain_on); // recalculate own_prepended_modules cache prepender.$$own_prepended_modules = own_prepended_modules(prepender); Opal.const_cache_version++; }; function flush_methods_in(module) { var proto = module.$$prototype, props = Object.getOwnPropertyNames(proto); for (var i = 0; i < props.length; i++) { var prop = props[i]; if (Opal.is_method(prop)) { delete proto[prop]; } } } function create_iclass(module) { var iclass = create_dummy_iclass(module); if (module.$$is_module) { module.$$iclasses.push(iclass); } return iclass; } // Dummy iclass doesn't receive updates when the module gets a new method. function create_dummy_iclass(module) { var iclass = {}, proto = module.$$prototype; if (proto.hasOwnProperty('$$dummy')) { proto = proto.$$define_methods_on; } var props = Object.getOwnPropertyNames(proto), length = props.length, i; for (i = 0; i < length; i++) { var prop = props[i]; $defineProperty(iclass, prop, proto[prop]); } $defineProperty(iclass, '$$iclass', true); $defineProperty(iclass, '$$module', module); return iclass; } function chain_iclasses(iclasses) { var length = iclasses.length, first = iclasses[0]; $defineProperty(first, '$$root', true); if (length === 1) { return { first: first, last: first }; } var previous = first; for (var i = 1; i < length; i++) { var current = iclasses[i]; $setPrototype(previous, current); previous = current; } return { first: iclasses[0], last: iclasses[length - 1] }; } // 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 the new class. Note: all bridged classes are set to inherit // from Object. // // Example: // // Opal.bridge(self, Function); // // @param klass [Class] the Ruby class to bridge // @param constructor [JS.Function] native JavaScript constructor to use // @return [Class] returns the passed Ruby class // Opal.bridge = function(native_klass, klass) { if (native_klass.hasOwnProperty('$$bridge')) { throw Opal.ArgumentError.$new("already bridged"); } var klass_to_inject, klass_reference; klass_to_inject = klass.$$super || Opal.Object; klass_reference = klass; var original_prototype = klass.$$prototype; // constructor is a JS function with a prototype chain like: // - constructor // - super // // What we need to do is to inject our class (with its prototype chain) // between constructor and super. For example, after injecting ::Object // into JS String we get: // // - constructor (window.String) // - Opal.Object // - Opal.Kernel // - Opal.BasicObject // - super (window.Object) // - null // $defineProperty(native_klass, '$$bridge', klass); $setPrototype(native_klass.prototype, (klass.$$super || Opal.Object).$$prototype); $defineProperty(klass, '$$prototype', native_klass.prototype); $defineProperty(klass.$$prototype, '$$class', klass); $defineProperty(klass, '$$constructor', native_klass); $defineProperty(klass, '$$bridge', true); }; function protoToModule(proto) { if (proto.hasOwnProperty('$$dummy')) { return; } else if (proto.hasOwnProperty('$$iclass')) { return proto.$$module; } else if (proto.hasOwnProperty('$$class')) { return proto.$$class; } } function own_ancestors(module) { return module.$$own_prepended_modules.concat([module]).concat(module.$$own_included_modules); } // The Array of ancestors for a given module/class Opal.ancestors = function(module) { if (!module) { return []; } if (module.$$ancestors_cache_version === Opal.const_cache_version) { return module.$$ancestors; } var result = [], i, mods, length; for (i = 0, mods = own_ancestors(module), length = mods.length; i < length; i++) { result.push(mods[i]); } if (module.$$super) { for (i = 0, mods = Opal.ancestors(module.$$super), length = mods.length; i < length; i++) { result.push(mods[i]); } } module.$$ancestors_cache_version = Opal.const_cache_version; module.$$ancestors = result; return result; }; Opal.included_modules = function(module) { var result = [], mod = null, proto = Object.getPrototypeOf(module.$$prototype); for (; proto && Object.getPrototypeOf(proto); proto = Object.getPrototypeOf(proto)) { mod = protoToModule(proto); if (mod && mod.$$is_module && proto.$$iclass && proto.$$included) { result.push(mod); } } return result; }; // Method Missing // -------------- // 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 stubs [Array] an array of method stubs to add // @return [undefined] Opal.add_stubs = function(stubs) { var proto = Opal.BasicObject.$$prototype; for (var i = 0, length = stubs.length; i < length; i++) { var stub = stubs[i], existing_method = proto[stub]; if (existing_method == null || existing_method.$$stub) { Opal.add_stub_for(proto, stub); } } }; // Add a method_missing stub function to the given prototype for the // given name. // // @param prototype [Prototype] the target prototype // @param stub [String] stub name to add (e.g. "$foo") // @return [undefined] Opal.add_stub_for = function(prototype, stub) { var method_missing_stub = Opal.stub_for(stub); $defineProperty(prototype, stub, method_missing_stub); }; // Generate the method_missing stub for a given method name. // // @param method_name [String] The js-name of the method to stub (e.g. "$foo") // @return [undefined] Opal.stub_for = function(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) var args_ary = new Array(arguments.length); for(var i = 0, l = args_ary.length; i < l; i++) { args_ary[i] = arguments[i]; } return this.$method_missing.apply(this, [method_name.slice(1)].concat(args_ary)); } method_missing_stub.$$stub = true; return method_missing_stub; }; // Methods // ------- // Arity count error dispatcher for methods // // @param actual [Fixnum] number of arguments given to method // @param expected [Fixnum] expected number of arguments // @param object [Object] owner of the method +meth+ // @param meth [String] method name that got wrong number of arguments // @raise [ArgumentError] Opal.ac = function(actual, expected, object, meth) { var inspect = ''; if (object.$$is_a_module) { inspect += object.$$name + '.'; } else { inspect += object.$$class.$$name + '#'; } inspect += meth; throw Opal.ArgumentError.$new('[' + inspect + '] wrong number of arguments(' + actual + ' for ' + expected + ')'); }; // Arity count error dispatcher for blocks // // @param actual [Fixnum] number of arguments given to block // @param expected [Fixnum] expected number of arguments // @param context [Object] context of the block definition // @raise [ArgumentError] Opal.block_ac = function(actual, expected, context) { var inspect = "`block in " + context + "'"; throw Opal.ArgumentError.$new(inspect + ': wrong number of arguments (' + actual + ' for ' + expected + ')'); }; // Super dispatcher Opal.find_super_dispatcher = function(obj, mid, current_func, defcheck, defs) { var jsid = '$' + mid, ancestors, super_method; if (obj.hasOwnProperty('$$meta')) { ancestors = Opal.ancestors(obj.$$meta); } else { ancestors = Opal.ancestors(obj.$$class); } var current_index = ancestors.indexOf(current_func.$$owner); for (var i = current_index + 1; i < ancestors.length; i++) { var ancestor = ancestors[i], proto = ancestor.$$prototype; if (proto.hasOwnProperty('$$dummy')) { proto = proto.$$define_methods_on; } if (proto.hasOwnProperty(jsid)) { var method = proto[jsid]; if (!method.$$stub) { super_method = method; } break; } } if (!defcheck && super_method == null && Opal.Kernel.$method_missing === obj.$method_missing) { // method_missing hasn't been explicitly defined throw Opal.NoMethodError.$new('super: no superclass method `'+mid+"' for "+obj, mid); } return super_method; }; // Iter dispatcher for super in a block Opal.find_iter_super_dispatcher = function(obj, jsid, current_func, defcheck, implicit) { var call_jsid = jsid; if (!current_func) { throw Opal.RuntimeError.$new("super called outside of method"); } if (implicit && current_func.$$define_meth) { throw Opal.RuntimeError.$new("implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly"); } if (current_func.$$def) { call_jsid = current_func.$$jsid; } return Opal.find_super_dispatcher(obj, call_jsid, current_func, defcheck); }; // 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; }; // Used to break out of a block. Opal.brk = function(val, breaker) { breaker.$v = val; throw breaker; }; // Builds a new unique breaker, this is to avoid multiple nested breaks to get // in the way of each other. Opal.new_brk = function() { return new Error('unexpected break'); }; // handles yield calls for 1 yielded arg Opal.yield1 = function(block, arg) { if (typeof(block) !== "function") { throw Opal.LocalJumpError.$new("no block given"); } var has_mlhs = block.$$has_top_level_mlhs_arg, has_trailing_comma = block.$$has_trailing_comma_in_args; if (block.length > 1 || ((has_mlhs || has_trailing_comma) && block.length === 1)) { arg = Opal.to_ary(arg); } if ((block.length > 1 || (has_trailing_comma && 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) { var args_ary = new Array(args.length); for(var i = 0, l = args_ary.length; i < l; i++) { args_ary[i] = args[i]; } return block.apply(null, args_ary); } 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 === Opal.JS.Error) { return candidate; } else if (candidate['$==='](exception)) { return candidate; } } return null; }; Opal.is_a = function(object, klass) { if (klass != null && object.$$meta === klass || object.$$class === klass) { return true; } if (object.$$is_number && klass.$$is_number_class) { return true; } var i, length, ancestors = Opal.ancestors(object.$$is_class ? Opal.get_singleton_class(object) : (object.$$meta || object.$$class)); for (i = 0, length = ancestors.length; i < length; i++) { if (ancestors[i] === klass) { return true; } } return false; }; // Helpers for extracting kwsplats // Used for: { **h } Opal.to_hash = function(value) { if (value.$$is_hash) { return value; } else if (value['$respond_to?']('to_hash', true)) { var hash = value.$to_hash(); if (hash.$$is_hash) { return hash; } else { throw Opal.TypeError.$new("Can't convert " + value.$$class + " to Hash (" + value.$$class + "#to_hash gives " + hash.$$class + ")"); } } else { throw Opal.TypeError.$new("no implicit conversion of " + value.$$class + " into Hash"); } }; // Helpers for implementing multiple assignment // Our code for extracting the values and assigning them only works if the // return value is a JS array. // So if we get an Array subclass, extract the wrapped JS array from it // Used for: a, b = something (no splat) Opal.to_ary = function(value) { if (value.$$is_array) { return value; } else if (value['$respond_to?']('to_ary', true)) { var ary = value.$to_ary(); if (ary === nil) { return [value]; } else if (ary.$$is_array) { return ary; } else { throw Opal.TypeError.$new("Can't convert " + value.$$class + " to Array (" + value.$$class + "#to_ary gives " + ary.$$class + ")"); } } else { return [value]; } }; // Used for: a, b = *something (with splat) Opal.to_a = function(value) { if (value.$$is_array) { // A splatted array must be copied return value.slice(); } else if (value['$respond_to?']('to_a', true)) { var ary = value.$to_a(); if (ary === nil) { return [value]; } else if (ary.$$is_array) { return ary; } else { throw Opal.TypeError.$new("Can't convert " + value.$$class + " to Array (" + value.$$class + "#to_a gives " + ary.$$class + ")"); } } else { return [value]; } }; // Used for extracting keyword arguments from arguments passed to // JS function. If provided +arguments+ list doesn't have a Hash // as a last item, returns a blank Hash. // // @param parameters [Array] // @return [Hash] // Opal.extract_kwargs = function(parameters) { var kwargs = parameters[parameters.length - 1]; if (kwargs != null && kwargs['$respond_to?']('to_hash', true)) { $splice.call(parameters, parameters.length - 1, 1); return kwargs.$to_hash(); } else { return Opal.hash2([], {}); } }; // 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] all keys used as named kwargs // @return [Hash] // Opal.kwrestargs = function(given_args, used_args) { var keys = [], map = {}, key , 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); }; // Calls passed method on a ruby object with arguments and block: // // Can take a method or a method name. // // 1. When method name gets passed it invokes it by its name // and calls 'method_missing' when object doesn't have this method. // Used internally by Opal to invoke method that takes a block or a splat. // 2. When method (i.e. method body) gets passed, it doesn't trigger 'method_missing' // because it doesn't know the name of the actual method. // Used internally by Opal to invoke 'super'. // // @example // var my_array = [1, 2, 3, 4] // Opal.send(my_array, 'length') # => 4 // Opal.send(my_array, my_array.$length) # => 4 // // Opal.send(my_array, 'reverse!') # => [4, 3, 2, 1] // Opal.send(my_array, my_array['$reverse!']') # => [4, 3, 2, 1] // // @param recv [Object] ruby object // @param method [Function, String] method body or name of the method // @param args [Array] arguments that will be passed to the method call // @param block [Function] ruby block // @return [Object] returning value of the method call Opal.send = function(recv, method, args, block) { var body = (typeof(method) === 'string') ? recv['$'+method] : method; if (body != null) { if (typeof block === 'function') { body.$$p = block; } return body.apply(recv, args); } return recv.$method_missing.apply(recv, [method].concat(args)); }; Opal.lambda = function(block) { block.$$is_lambda = true; return block; }; // 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 obj [Object, Class] the actual obj to define method for // @param jsid [String] the JavaScript friendly method name (e.g. '$foo') // @param body [JS.Function] the literal JavaScript function used as method // @return [null] // Opal.def = function(obj, jsid, body) { // Special case for a method definition in the // top-level namespace if (obj === Opal.top) { Opal.defn(Opal.Object, jsid, body) } // if instance_eval is invoked on a module/class, it sets inst_eval_mod else if (!obj.$$eval && obj.$$is_a_module) { Opal.defn(obj, jsid, body); } else { Opal.defs(obj, jsid, body); } }; // Define method on a module or class (see Opal.def). Opal.defn = function(module, jsid, body) { body.displayName = jsid; body.$$owner = module; var proto = module.$$prototype; if (proto.hasOwnProperty('$$dummy')) { proto = proto.$$define_methods_on; } $defineProperty(proto, jsid, body); if (module.$$is_module) { if (module.$$module_function) { Opal.defs(module, jsid, body) } for (var i = 0, iclasses = module.$$iclasses, length = iclasses.length; i < length; i++) { var iclass = iclasses[i]; $defineProperty(iclass, jsid, body); } } var singleton_of = module.$$singleton_of; if (module.$method_added && !module.$method_added.$$stub && !singleton_of) { module.$method_added(jsid.substr(1)); } else if (singleton_of && singleton_of.$singleton_method_added && !singleton_of.$singleton_method_added.$$stub) { singleton_of.$singleton_method_added(jsid.substr(1)); } }; // Define a singleton method on the given object (see Opal.def). Opal.defs = function(obj, jsid, body) { if (obj.$$is_string || obj.$$is_number) { throw Opal.TypeError.$new("can't define singleton"); } Opal.defn(Opal.get_singleton_class(obj), jsid, body) }; // Called from #remove_method. Opal.rdef = function(obj, jsid) { if (!$hasOwn.call(obj.$$prototype, jsid)) { throw Opal.NameError.$new("method '" + jsid.substr(1) + "' not defined in " + obj.$name()); } delete obj.$$prototype[jsid]; if (obj.$$is_singleton) { if (obj.$$prototype.$singleton_method_removed && !obj.$$prototype.$singleton_method_removed.$$stub) { obj.$$prototype.$singleton_method_removed(jsid.substr(1)); } } else { if (obj.$method_removed && !obj.$method_removed.$$stub) { obj.$method_removed(jsid.substr(1)); } } }; // Called from #undef_method. Opal.udef = function(obj, jsid) { if (!obj.$$prototype[jsid] || obj.$$prototype[jsid].$$stub) { throw Opal.NameError.$new("method '" + jsid.substr(1) + "' not defined in " + obj.$name()); } Opal.add_stub_for(obj.$$prototype, jsid); if (obj.$$is_singleton) { if (obj.$$prototype.$singleton_method_undefined && !obj.$$prototype.$singleton_method_undefined.$$stub) { obj.$$prototype.$singleton_method_undefined(jsid.substr(1)); } } else { if (obj.$method_undefined && !obj.$method_undefined.$$stub) { obj.$method_undefined(jsid.substr(1)); } } }; function is_method_body(body) { return (typeof(body) === "function" && !body.$$stub); } Opal.alias = function(obj, name, old) { var id = '$' + name, old_id = '$' + old, body = obj.$$prototype['$' + old], alias; // When running inside #instance_eval the alias refers to class methods. if (obj.$$eval) { return Opal.alias(Opal.get_singleton_class(obj), name, old); } if (!is_method_body(body)) { var ancestor = obj.$$super; while (typeof(body) !== "function" && ancestor) { body = ancestor[old_id]; ancestor = ancestor.$$super; } if (!is_method_body(body) && obj.$$is_module) { // try to look into Object body = Opal.Object.$$prototype[old_id] } if (!is_method_body(body)) { throw Opal.NameError.$new("undefined method `" + old + "' for class `" + obj.$name() + "'") } } // If the body is itself an alias use the original body // to keep the max depth at 1. if (body.$$alias_of) body = body.$$alias_of; // We need a wrapper because otherwise properties // would be ovrewritten on the original body. alias = function() { var block = alias.$$p, args, i, ii; args = new Array(arguments.length); for(i = 0, ii = arguments.length; i < ii; i++) { args[i] = arguments[i]; } if (block != null) { alias.$$p = null } return Opal.send(this, body, args, block); }; // Try to make the browser pick the right name alias.displayName = name; alias.length = body.length; alias.$$arity = body.$$arity; alias.$$parameters = body.$$parameters; alias.$$source_location = body.$$source_location; alias.$$alias_of = body; alias.$$alias_name = name; Opal.defn(obj, id, alias); return obj; }; Opal.alias_native = function(obj, name, native_name) { var id = '$' + name, body = obj.$$prototype[native_name]; if (typeof(body) !== "function" || body.$$stub) { throw Opal.NameError.$new("undefined native method `" + native_name + "' for class `" + obj.$name() + "'") } Opal.defn(obj, id, body); return obj; }; // Hashes // ------ Opal.hash_init = function(hash) { hash.$$smap = Object.create(null); hash.$$map = Object.create(null); hash.$$keys = []; }; Opal.hash_clone = function(from_hash, to_hash) { to_hash.$$none = from_hash.$$none; to_hash.$$proc = from_hash.$$proc; for (var i = 0, keys = from_hash.$$keys, smap = from_hash.$$smap, len = keys.length, key, value; i < len; i++) { key = keys[i]; if (key.$$is_string) { value = smap[key]; } else { value = key.value; key = key.key; } Opal.hash_put(to_hash, key, value); } }; Opal.hash_put = function(hash, key, value) { if (key.$$is_string) { if (!$hasOwn.call(hash.$$smap, key)) { hash.$$keys.push(key); } hash.$$smap[key] = value; return; } var key_hash, bucket, last_bucket; key_hash = hash.$$by_identity ? Opal.id(key) : key.$hash(); if (!$hasOwn.call(hash.$$map, key_hash)) { bucket = {key: key, key_hash: key_hash, value: value}; hash.$$keys.push(bucket); hash.$$map[key_hash] = bucket; return; } bucket = hash.$$map[key_hash]; while (bucket) { if (key === bucket.key || key['$eql?'](bucket.key)) { last_bucket = undefined; bucket.value = value; break; } last_bucket = bucket; bucket = bucket.next; } if (last_bucket) { bucket = {key: key, key_hash: key_hash, value: value}; hash.$$keys.push(bucket); last_bucket.next = bucket; } }; Opal.hash_get = function(hash, key) { if (key.$$is_string) { if ($hasOwn.call(hash.$$smap, key)) { return hash.$$smap[key]; } return; } var key_hash, bucket; key_hash = hash.$$by_identity ? Opal.id(key) : key.$hash(); if ($hasOwn.call(hash.$$map, key_hash)) { bucket = hash.$$map[key_hash]; while (bucket) { if (key === bucket.key || key['$eql?'](bucket.key)) { return bucket.value; } bucket = bucket.next; } } }; Opal.hash_delete = function(hash, key) { var i, keys = hash.$$keys, length = keys.length, value; if (key.$$is_string) { if (!$hasOwn.call(hash.$$smap, key)) { return; } for (i = 0; i < length; i++) { if (keys[i] === key) { keys.splice(i, 1); break; } } value = hash.$$smap[key]; delete hash.$$smap[key]; return value; } var key_hash = key.$hash(); if (!$hasOwn.call(hash.$$map, key_hash)) { return; } var bucket = hash.$$map[key_hash], last_bucket; while (bucket) { if (key === bucket.key || key['$eql?'](bucket.key)) { value = bucket.value; for (i = 0; i < length; i++) { if (keys[i] === bucket) { keys.splice(i, 1); break; } } if (last_bucket && bucket.next) { last_bucket.next = bucket.next; } else if (last_bucket) { delete last_bucket.next; } else if (bucket.next) { hash.$$map[key_hash] = bucket.next; } else { delete hash.$$map[key_hash]; } return value; } last_bucket = bucket; bucket = bucket.next; } }; Opal.hash_rehash = function(hash) { for (var i = 0, length = hash.$$keys.length, key_hash, bucket, last_bucket; i < length; i++) { if (hash.$$keys[i].$$is_string) { continue; } key_hash = hash.$$keys[i].key.$hash(); if (key_hash === hash.$$keys[i].key_hash) { continue; } bucket = hash.$$map[hash.$$keys[i].key_hash]; last_bucket = undefined; while (bucket) { if (bucket === hash.$$keys[i]) { if (last_bucket && bucket.next) { last_bucket.next = bucket.next; } else if (last_bucket) { delete last_bucket.next; } else if (bucket.next) { hash.$$map[hash.$$keys[i].key_hash] = bucket.next; } else { delete hash.$$map[hash.$$keys[i].key_hash]; } break; } last_bucket = bucket; bucket = bucket.next; } hash.$$keys[i].key_hash = key_hash; if (!$hasOwn.call(hash.$$map, key_hash)) { hash.$$map[key_hash] = hash.$$keys[i]; continue; } bucket = hash.$$map[key_hash]; last_bucket = undefined; while (bucket) { if (bucket === hash.$$keys[i]) { last_bucket = undefined; break; } last_bucket = bucket; bucket = bucket.next; } if (last_bucket) { last_bucket.next = hash.$$keys[i]; } } }; Opal.hash = function() { var arguments_length = arguments.length, args, hash, i, length, key, value; if (arguments_length === 1 && arguments[0].$$is_hash) { return arguments[0]; } hash = new Opal.Hash(); Opal.hash_init(hash); if (arguments_length === 1 && arguments[0].$$is_array) { args = arguments[0]; length = args.length; for (i = 0; i < length; i++) { if (args[i].length !== 2) { throw Opal.ArgumentError.$new("value not of length 2: " + args[i].$inspect()); } key = args[i][0]; value = args[i][1]; Opal.hash_put(hash, key, value); } return hash; } if (arguments_length === 1) { args = arguments[0]; for (key in args) { if ($hasOwn.call(args, key)) { value = args[key]; Opal.hash_put(hash, key, value); } } return hash; } if (arguments_length % 2 !== 0) { throw Opal.ArgumentError.$new("odd number of arguments for Hash"); } for (i = 0; i < arguments_length; i += 2) { key = arguments[i]; value = arguments[i + 1]; Opal.hash_put(hash, key, value); } return hash; }; // A faster Hash 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, smap) { var hash = new Opal.Hash(); hash.$$smap = smap; hash.$$map = Object.create(null); hash.$$keys = keys; 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(); range.begin = first; range.end = last; range.excl = exc; return range; }; // Get the ivar name for a given name. // Mostly adds a trailing $ to reserved names. // Opal.ivar = function(name) { if ( // properties name === "constructor" || name === "displayName" || name === "__count__" || name === "__noSuchMethod__" || name === "__parent__" || name === "__proto__" || // methods name === "hasOwnProperty" || name === "valueOf" ) { return name + "$"; } return name; }; // Regexps // ------- // Escape Regexp special chars letting the resulting string be used to build // a new Regexp. // Opal.escape_regexp = function(str) { return str.replace(/([-[\]\/{}()*+?.^$\\| ])/g, '\\$1') .replace(/[\n]/g, '\\n') .replace(/[\r]/g, '\\r') .replace(/[\f]/g, '\\f') .replace(/[\t]/g, '\\t'); }; // Create a global Regexp from a RegExp object and cache the result // on the object itself ($$g attribute). // Opal.global_regexp = function(pattern) { if (pattern.global) { return pattern; // RegExp already has the global flag } if (pattern.$$g == null) { pattern.$$g = new RegExp(pattern.source, (pattern.multiline ? 'gm' : 'g') + (pattern.ignoreCase ? 'i' : '')); } else { pattern.$$g.lastIndex = null; // reset lastIndex property } return pattern.$$g; }; // Create a global multiline Regexp from a RegExp object and cache the result // on the object itself ($$gm or $$g attribute). // Opal.global_multiline_regexp = function(pattern) { var result; if (pattern.multiline) { if (pattern.global) { return pattern; // RegExp already has the global and multiline flag } // we are using the $$g attribute because the Regexp is already multiline if (pattern.$$g != null) { result = pattern.$$g; } else { result = pattern.$$g = new RegExp(pattern.source, 'gm' + (pattern.ignoreCase ? 'i' : '')); } } else if (pattern.$$gm != null) { result = pattern.$$gm; } else { result = pattern.$$gm = new RegExp(pattern.source, 'gm' + (pattern.ignoreCase ? 'i' : '')); } result.lastIndex = null; // reset lastIndex property return result; }; // Require system // -------------- Opal.modules = {}; Opal.loaded_features = ['corelib/runtime']; Opal.current_dir = '.'; Opal.require_table = {'corelib/runtime': true}; Opal.normalize = function(path) { var parts, part, new_parts = [], SEPARATOR = '/'; if (Opal.current_dir !== '.') { path = Opal.current_dir.replace(/\/*$/, '/') + path; } path = path.replace(/^\.\//, ''); path = path.replace(/\.(rb|opal|js)$/, ''); 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); }; Opal.loaded = function(paths) { var i, l, path; for (i = 0, l = paths.length; i < l; i++) { path = Opal.normalize(paths[i]); if (Opal.require_table[path]) { continue; } Opal.loaded_features.push(path); Opal.require_table[path] = true; } }; Opal.load = function(path) { path = Opal.normalize(path); Opal.loaded([path]); var module = Opal.modules[path]; if (module) { module(Opal); } else { var severity = Opal.config.missing_require_severity; var message = 'cannot load such file -- ' + path; if (severity === "error") { if (Opal.LoadError) { throw Opal.LoadError.$new(message) } else { throw message } } else if (severity === "warning") { console.warn('WARNING: LoadError: ' + message); } } return true; }; Opal.require = function(path) { path = Opal.normalize(path); if (Opal.require_table[path]) { return false; } return Opal.load(path); }; // Initialization // -------------- function $BasicObject() {} function $Object() {} function $Module() {} function $Class() {} Opal.BasicObject = BasicObject = Opal.allocate_class('BasicObject', null, $BasicObject); Opal.Object = _Object = Opal.allocate_class('Object', Opal.BasicObject, $Object); Opal.Module = Module = Opal.allocate_class('Module', Opal.Object, $Module); Opal.Class = Class = Opal.allocate_class('Class', Opal.Module, $Class); $setPrototype(Opal.BasicObject, Opal.Class.$$prototype); $setPrototype(Opal.Object, Opal.Class.$$prototype); $setPrototype(Opal.Module, Opal.Class.$$prototype); $setPrototype(Opal.Class, Opal.Class.$$prototype); // BasicObject can reach itself, avoid const_set to skip the $$base_module logic BasicObject.$$const["BasicObject"] = BasicObject; // Assign basic constants Opal.const_set(_Object, "BasicObject", BasicObject); Opal.const_set(_Object, "Object", _Object); Opal.const_set(_Object, "Module", Module); Opal.const_set(_Object, "Class", Class); // Fix booted classes to have correct .class value BasicObject.$$class = Class; _Object.$$class = Class; Module.$$class = Class; Class.$$class = Class; // Forward .toString() to #to_s $defineProperty(_Object.$$prototype, 'toString', function() { var to_s = this.$to_s(); if (to_s.$$is_string && typeof(to_s) === 'object') { // a string created using new String('string') return to_s.valueOf(); } else { return to_s; } }); // Make Kernel#require immediately available as it's needed to require all the // other corelib files. $defineProperty(_Object.$$prototype, '$require', Opal.require); // Add a short helper to navigate constants manually. // @example // Opal.$$.Regexp.$$.IGNORECASE Opal.$$ = _Object.$$; // Instantiate the main object Opal.top = new _Object(); Opal.top.$to_s = Opal.top.$inspect = function() { return 'main' }; // Nil function $NilClass() {} Opal.NilClass = Opal.allocate_class('NilClass', Opal.Object, $NilClass); Opal.const_set(_Object, 'NilClass', Opal.NilClass); nil = Opal.nil = new Opal.NilClass(); nil.$$id = nil_id; nil.call = nil.apply = function() { throw Opal.LocalJumpError.$new('no block given'); }; // Errors Opal.breaker = new Error('unexpected break (old)'); Opal.returner = new Error('unexpected return'); TypeError.$$super = Error; }).call(this); Opal.loaded(["corelib/runtime.js"]); /* Generated by Opal 1.0.3 */ Opal.modules["corelib/helpers"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy; Opal.add_stubs(['$new', '$class', '$===', '$respond_to?', '$raise', '$type_error', '$__send__', '$coerce_to', '$nil?', '$<=>', '$coerce_to!', '$!=', '$[]', '$upcase']); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting), $Opal_bridge$1, $Opal_type_error$2, $Opal_coerce_to$3, $Opal_coerce_to$excl$4, $Opal_coerce_to$ques$5, $Opal_try_convert$6, $Opal_compare$7, $Opal_destructure$8, $Opal_respond_to$ques$9, $Opal_inspect_obj$10, $Opal_instance_variable_name$excl$11, $Opal_class_variable_name$excl$12, $Opal_const_name$excl$13, $Opal_pristine$14; Opal.defs(self, '$bridge', $Opal_bridge$1 = function $$bridge(constructor, klass) { var self = this; return Opal.bridge(constructor, klass); }, $Opal_bridge$1.$$arity = 2); Opal.defs(self, '$type_error', $Opal_type_error$2 = function $$type_error(object, type, method, coerced) { var $a, self = this; if (method == null) { method = nil; }; if (coerced == null) { coerced = nil; }; if ($truthy(($truthy($a = method) ? coerced : $a))) { return $$($nesting, 'TypeError').$new("" + "can't convert " + (object.$class()) + " into " + (type) + " (" + (object.$class()) + "#" + (method) + " gives " + (coerced.$class()) + ")") } else { return $$($nesting, 'TypeError').$new("" + "no implicit conversion of " + (object.$class()) + " into " + (type)) }; }, $Opal_type_error$2.$$arity = -3); Opal.defs(self, '$coerce_to', $Opal_coerce_to$3 = function $$coerce_to(object, type, method) { var self = this; if ($truthy(type['$==='](object))) { return object}; if ($truthy(object['$respond_to?'](method))) { } else { self.$raise(self.$type_error(object, type)) }; return object.$__send__(method); }, $Opal_coerce_to$3.$$arity = 3); Opal.defs(self, '$coerce_to!', $Opal_coerce_to$excl$4 = function(object, type, method) { var self = this, coerced = nil; coerced = self.$coerce_to(object, type, method); if ($truthy(type['$==='](coerced))) { } else { self.$raise(self.$type_error(object, type, method, coerced)) }; return coerced; }, $Opal_coerce_to$excl$4.$$arity = 3); Opal.defs(self, '$coerce_to?', $Opal_coerce_to$ques$5 = function(object, type, method) { var self = this, coerced = nil; if ($truthy(object['$respond_to?'](method))) { } else { return nil }; coerced = self.$coerce_to(object, type, method); if ($truthy(coerced['$nil?']())) { return nil}; if ($truthy(type['$==='](coerced))) { } else { self.$raise(self.$type_error(object, type, method, coerced)) }; return coerced; }, $Opal_coerce_to$ques$5.$$arity = 3); Opal.defs(self, '$try_convert', $Opal_try_convert$6 = function $$try_convert(object, type, method) { var self = this; if ($truthy(type['$==='](object))) { return object}; if ($truthy(object['$respond_to?'](method))) { return object.$__send__(method) } else { return nil }; }, $Opal_try_convert$6.$$arity = 3); Opal.defs(self, '$compare', $Opal_compare$7 = function $$compare(a, b) { var self = this, compare = nil; compare = a['$<=>'](b); if ($truthy(compare === nil)) { self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + (a.$class()) + " with " + (b.$class()) + " failed")}; return compare; }, $Opal_compare$7.$$arity = 2); Opal.defs(self, '$destructure', $Opal_destructure$8 = function $$destructure(args) { var self = this; if (args.length == 1) { return args[0]; } else if (args.$$is_array) { return args; } else { var args_ary = new Array(args.length); for(var i = 0, l = args_ary.length; i < l; i++) { args_ary[i] = args[i]; } return args_ary; } }, $Opal_destructure$8.$$arity = 1); Opal.defs(self, '$respond_to?', $Opal_respond_to$ques$9 = function(obj, method, include_all) { var self = this; if (include_all == null) { include_all = false; }; if (obj == null || !obj.$$class) { return false; } ; return obj['$respond_to?'](method, include_all); }, $Opal_respond_to$ques$9.$$arity = -3); Opal.defs(self, '$inspect_obj', $Opal_inspect_obj$10 = function $$inspect_obj(obj) { var self = this; return Opal.inspect(obj); }, $Opal_inspect_obj$10.$$arity = 1); Opal.defs(self, '$instance_variable_name!', $Opal_instance_variable_name$excl$11 = function(name) { var self = this; name = $$($nesting, 'Opal')['$coerce_to!'](name, $$($nesting, 'String'), "to_str"); if ($truthy(/^@[a-zA-Z_][a-zA-Z0-9_]*?$/.test(name))) { } else { self.$raise($$($nesting, 'NameError').$new("" + "'" + (name) + "' is not allowed as an instance variable name", name)) }; return name; }, $Opal_instance_variable_name$excl$11.$$arity = 1); Opal.defs(self, '$class_variable_name!', $Opal_class_variable_name$excl$12 = function(name) { var self = this; name = $$($nesting, 'Opal')['$coerce_to!'](name, $$($nesting, 'String'), "to_str"); if ($truthy(name.length < 3 || name.slice(0,2) !== '@@')) { self.$raise($$($nesting, 'NameError').$new("" + "`" + (name) + "' is not allowed as a class variable name", name))}; return name; }, $Opal_class_variable_name$excl$12.$$arity = 1); Opal.defs(self, '$const_name!', $Opal_const_name$excl$13 = function(const_name) { var self = this; const_name = $$($nesting, 'Opal')['$coerce_to!'](const_name, $$($nesting, 'String'), "to_str"); if ($truthy(const_name['$[]'](0)['$!='](const_name['$[]'](0).$upcase()))) { self.$raise($$($nesting, 'NameError'), "" + "wrong constant name " + (const_name))}; return const_name; }, $Opal_const_name$excl$13.$$arity = 1); Opal.defs(self, '$pristine', $Opal_pristine$14 = function $$pristine(owner_class, $a) { var $post_args, method_names, self = this; $post_args = Opal.slice.call(arguments, 1, arguments.length); method_names = $post_args;; var method_name, method; for (var i = method_names.length - 1; i >= 0; i--) { method_name = method_names[i]; method = owner_class.$$prototype['$'+method_name]; if (method && !method.$$stub) { method.$$pristine = true; } } ; return nil; }, $Opal_pristine$14.$$arity = -2); })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/module"] = function(Opal) { function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $lambda = Opal.lambda, $range = Opal.range, $hash2 = Opal.hash2; Opal.add_stubs(['$module_eval', '$to_proc', '$===', '$raise', '$equal?', '$<', '$>', '$nil?', '$attr_reader', '$attr_writer', '$class_variable_name!', '$new', '$const_name!', '$=~', '$inject', '$split', '$const_get', '$==', '$!~', '$start_with?', '$bind', '$call', '$class', '$append_features', '$included', '$name', '$cover?', '$size', '$merge', '$compile', '$proc', '$any?', '$prepend_features', '$prepended', '$to_s', '$__id__', '$constants', '$include?', '$copy_class_variables', '$copy_constants']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Module'); var $nesting = [self].concat($parent_nesting), $Module_allocate$1, $Module_initialize$2, $Module_$eq_eq_eq$3, $Module_$lt$4, $Module_$lt_eq$5, $Module_$gt$6, $Module_$gt_eq$7, $Module_$lt_eq_gt$8, $Module_alias_method$9, $Module_alias_native$10, $Module_ancestors$11, $Module_append_features$12, $Module_attr_accessor$13, $Module_attr_reader$14, $Module_attr_writer$15, $Module_autoload$16, $Module_class_variables$17, $Module_class_variable_get$18, $Module_class_variable_set$19, $Module_class_variable_defined$ques$20, $Module_remove_class_variable$21, $Module_constants$22, $Module_constants$23, $Module_nesting$24, $Module_const_defined$ques$25, $Module_const_get$26, $Module_const_missing$28, $Module_const_set$29, $Module_public_constant$30, $Module_define_method$31, $Module_remove_method$33, $Module_singleton_class$ques$34, $Module_include$35, $Module_included_modules$36, $Module_include$ques$37, $Module_instance_method$38, $Module_instance_methods$39, $Module_included$40, $Module_extended$41, $Module_extend_object$42, $Module_method_added$43, $Module_method_removed$44, $Module_method_undefined$45, $Module_module_eval$46, $Module_module_exec$48, $Module_method_defined$ques$49, $Module_module_function$50, $Module_name$51, $Module_prepend$52, $Module_prepend_features$53, $Module_prepended$54, $Module_remove_const$55, $Module_to_s$56, $Module_undef_method$57, $Module_instance_variables$58, $Module_dup$59, $Module_copy_class_variables$60, $Module_copy_constants$61; Opal.defs(self, '$allocate', $Module_allocate$1 = function $$allocate() { var self = this; var module = Opal.allocate_module(nil, function(){}); // Link the prototype of Module subclasses if (self !== Opal.Module) Object.setPrototypeOf(module, self.$$prototype); return module; }, $Module_allocate$1.$$arity = 0); Opal.def(self, '$initialize', $Module_initialize$2 = function $$initialize() { var $iter = $Module_initialize$2.$$p, block = $iter || nil, self = this; if ($iter) $Module_initialize$2.$$p = null; if ($iter) $Module_initialize$2.$$p = null;; if ((block !== nil)) { return $send(self, 'module_eval', [], block.$to_proc()) } else { return nil }; }, $Module_initialize$2.$$arity = 0); Opal.def(self, '$===', $Module_$eq_eq_eq$3 = function(object) { var self = this; if ($truthy(object == null)) { return false}; return Opal.is_a(object, self);; }, $Module_$eq_eq_eq$3.$$arity = 1); Opal.def(self, '$<', $Module_$lt$4 = function(other) { var self = this; if ($truthy($$($nesting, 'Module')['$==='](other))) { } else { self.$raise($$($nesting, 'TypeError'), "compared with non class/module") }; var working = self, ancestors, i, length; if (working === other) { return false; } for (i = 0, ancestors = Opal.ancestors(self), length = ancestors.length; i < length; i++) { if (ancestors[i] === other) { return true; } } for (i = 0, ancestors = Opal.ancestors(other), length = ancestors.length; i < length; i++) { if (ancestors[i] === self) { return false; } } return nil; ; }, $Module_$lt$4.$$arity = 1); Opal.def(self, '$<=', $Module_$lt_eq$5 = function(other) { var $a, self = this; return ($truthy($a = self['$equal?'](other)) ? $a : $rb_lt(self, other)) }, $Module_$lt_eq$5.$$arity = 1); Opal.def(self, '$>', $Module_$gt$6 = function(other) { var self = this; if ($truthy($$($nesting, 'Module')['$==='](other))) { } else { self.$raise($$($nesting, 'TypeError'), "compared with non class/module") }; return $rb_lt(other, self); }, $Module_$gt$6.$$arity = 1); Opal.def(self, '$>=', $Module_$gt_eq$7 = function(other) { var $a, self = this; return ($truthy($a = self['$equal?'](other)) ? $a : $rb_gt(self, other)) }, $Module_$gt_eq$7.$$arity = 1); Opal.def(self, '$<=>', $Module_$lt_eq_gt$8 = function(other) { var self = this, lt = nil; if (self === other) { return 0; } ; if ($truthy($$($nesting, 'Module')['$==='](other))) { } else { return nil }; lt = $rb_lt(self, other); if ($truthy(lt['$nil?']())) { return nil}; if ($truthy(lt)) { return -1 } else { return 1 }; }, $Module_$lt_eq_gt$8.$$arity = 1); Opal.def(self, '$alias_method', $Module_alias_method$9 = function $$alias_method(newname, oldname) { var self = this; Opal.alias(self, newname, oldname); return self; }, $Module_alias_method$9.$$arity = 2); Opal.def(self, '$alias_native', $Module_alias_native$10 = function $$alias_native(mid, jsid) { var self = this; if (jsid == null) { jsid = mid; }; Opal.alias_native(self, mid, jsid); return self; }, $Module_alias_native$10.$$arity = -2); Opal.def(self, '$ancestors', $Module_ancestors$11 = function $$ancestors() { var self = this; return Opal.ancestors(self); }, $Module_ancestors$11.$$arity = 0); Opal.def(self, '$append_features', $Module_append_features$12 = function $$append_features(includer) { var self = this; Opal.append_features(self, includer); return self; }, $Module_append_features$12.$$arity = 1); Opal.def(self, '$attr_accessor', $Module_attr_accessor$13 = function $$attr_accessor($a) { var $post_args, names, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; $send(self, 'attr_reader', Opal.to_a(names)); return $send(self, 'attr_writer', Opal.to_a(names)); }, $Module_attr_accessor$13.$$arity = -1); Opal.alias(self, "attr", "attr_accessor"); Opal.def(self, '$attr_reader', $Module_attr_reader$14 = function $$attr_reader($a) { var $post_args, names, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; var proto = self.$$prototype; for (var i = names.length - 1; i >= 0; i--) { var name = names[i], id = '$' + name, ivar = Opal.ivar(name); // the closure here is needed because name will change at the next // cycle, I wish we could use let. var body = (function(ivar) { return function() { if (this[ivar] == null) { return nil; } else { return this[ivar]; } }; })(ivar); // initialize the instance variable as nil Opal.defineProperty(proto, ivar, nil); body.$$parameters = []; body.$$arity = 0; Opal.defn(self, id, body); } ; return nil; }, $Module_attr_reader$14.$$arity = -1); Opal.def(self, '$attr_writer', $Module_attr_writer$15 = function $$attr_writer($a) { var $post_args, names, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; var proto = self.$$prototype; for (var i = names.length - 1; i >= 0; i--) { var name = names[i], id = '$' + name + '=', ivar = Opal.ivar(name); // the closure here is needed because name will change at the next // cycle, I wish we could use let. var body = (function(ivar){ return function(value) { return this[ivar] = value; } })(ivar); body.$$parameters = [['req']]; body.$$arity = 1; // initialize the instance variable as nil Opal.defineProperty(proto, ivar, nil); Opal.defn(self, id, body); } ; return nil; }, $Module_attr_writer$15.$$arity = -1); Opal.def(self, '$autoload', $Module_autoload$16 = function $$autoload(const$, path) { var self = this; if (self.$$autoload == null) self.$$autoload = {}; Opal.const_cache_version++; self.$$autoload[const$] = path; return nil; }, $Module_autoload$16.$$arity = 2); Opal.def(self, '$class_variables', $Module_class_variables$17 = function $$class_variables() { var self = this; return Object.keys(Opal.class_variables(self)); }, $Module_class_variables$17.$$arity = 0); Opal.def(self, '$class_variable_get', $Module_class_variable_get$18 = function $$class_variable_get(name) { var self = this; name = $$($nesting, 'Opal')['$class_variable_name!'](name); var value = Opal.class_variables(self)[name]; if (value == null) { self.$raise($$($nesting, 'NameError').$new("" + "uninitialized class variable " + (name) + " in " + (self), name)) } return value; ; }, $Module_class_variable_get$18.$$arity = 1); Opal.def(self, '$class_variable_set', $Module_class_variable_set$19 = function $$class_variable_set(name, value) { var self = this; name = $$($nesting, 'Opal')['$class_variable_name!'](name); return Opal.class_variable_set(self, name, value);; }, $Module_class_variable_set$19.$$arity = 2); Opal.def(self, '$class_variable_defined?', $Module_class_variable_defined$ques$20 = function(name) { var self = this; name = $$($nesting, 'Opal')['$class_variable_name!'](name); return Opal.class_variables(self).hasOwnProperty(name);; }, $Module_class_variable_defined$ques$20.$$arity = 1); Opal.def(self, '$remove_class_variable', $Module_remove_class_variable$21 = function $$remove_class_variable(name) { var self = this; name = $$($nesting, 'Opal')['$class_variable_name!'](name); if (Opal.hasOwnProperty.call(self.$$cvars, name)) { var value = self.$$cvars[name]; delete self.$$cvars[name]; return value; } else { self.$raise($$($nesting, 'NameError'), "" + "cannot remove " + (name) + " for " + (self)) } ; }, $Module_remove_class_variable$21.$$arity = 1); Opal.def(self, '$constants', $Module_constants$22 = function $$constants(inherit) { var self = this; if (inherit == null) { inherit = true; }; return Opal.constants(self, inherit);; }, $Module_constants$22.$$arity = -1); Opal.defs(self, '$constants', $Module_constants$23 = function $$constants(inherit) { var self = this; ; if (inherit == null) { var nesting = (self.$$nesting || []).concat(Opal.Object), constant, constants = {}, i, ii; for(i = 0, ii = nesting.length; i < ii; i++) { for (constant in nesting[i].$$const) { constants[constant] = true; } } return Object.keys(constants); } else { return Opal.constants(self, inherit) } ; }, $Module_constants$23.$$arity = -1); Opal.defs(self, '$nesting', $Module_nesting$24 = function $$nesting() { var self = this; return self.$$nesting || []; }, $Module_nesting$24.$$arity = 0); Opal.def(self, '$const_defined?', $Module_const_defined$ques$25 = function(name, inherit) { var self = this; if (inherit == null) { inherit = true; }; name = $$($nesting, 'Opal')['$const_name!'](name); if ($truthy(name['$=~']($$$($$($nesting, 'Opal'), 'CONST_NAME_REGEXP')))) { } else { self.$raise($$($nesting, 'NameError').$new("" + "wrong constant name " + (name), name)) }; var module, modules = [self], module_constants, i, ii; // Add up ancestors if inherit is true if (inherit) { modules = modules.concat(Opal.ancestors(self)); // Add Object's ancestors if it's a module – modules have no ancestors otherwise if (self.$$is_module) { modules = modules.concat([Opal.Object]).concat(Opal.ancestors(Opal.Object)); } } for (i = 0, ii = modules.length; i < ii; i++) { module = modules[i]; if (module.$$const[name] != null) { return true; } } return false; ; }, $Module_const_defined$ques$25.$$arity = -2); Opal.def(self, '$const_get', $Module_const_get$26 = function $$const_get(name, inherit) { var $$27, self = this; if (inherit == null) { inherit = true; }; name = $$($nesting, 'Opal')['$const_name!'](name); if (name.indexOf('::') === 0 && name !== '::'){ name = name.slice(2); } ; if ($truthy(name.indexOf('::') != -1 && name != '::')) { return $send(name.$split("::"), 'inject', [self], ($$27 = function(o, c){var self = $$27.$$s || this; if (o == null) { o = nil; }; if (c == null) { c = nil; }; return o.$const_get(c);}, $$27.$$s = self, $$27.$$arity = 2, $$27))}; if ($truthy(name['$=~']($$$($$($nesting, 'Opal'), 'CONST_NAME_REGEXP')))) { } else { self.$raise($$($nesting, 'NameError').$new("" + "wrong constant name " + (name), name)) }; if (inherit) { return $$([self], name); } else { return Opal.const_get_local(self, name); } ; }, $Module_const_get$26.$$arity = -2); Opal.def(self, '$const_missing', $Module_const_missing$28 = function $$const_missing(name) { var self = this, full_const_name = nil; if (self.$$autoload) { var file = self.$$autoload[name]; if (file) { self.$require(file); return self.$const_get(name); } } ; full_const_name = (function() {if (self['$==']($$($nesting, 'Object'))) { return name } else { return "" + (self) + "::" + (name) }; return nil; })(); return self.$raise($$($nesting, 'NameError').$new("" + "uninitialized constant " + (full_const_name), name)); }, $Module_const_missing$28.$$arity = 1); Opal.def(self, '$const_set', $Module_const_set$29 = function $$const_set(name, value) { var $a, self = this; name = $$($nesting, 'Opal')['$const_name!'](name); if ($truthy(($truthy($a = name['$!~']($$$($$($nesting, 'Opal'), 'CONST_NAME_REGEXP'))) ? $a : name['$start_with?']("::")))) { self.$raise($$($nesting, 'NameError').$new("" + "wrong constant name " + (name), name))}; Opal.const_set(self, name, value); return value; }, $Module_const_set$29.$$arity = 2); Opal.def(self, '$public_constant', $Module_public_constant$30 = function $$public_constant(const_name) { var self = this; return nil }, $Module_public_constant$30.$$arity = 1); Opal.def(self, '$define_method', $Module_define_method$31 = function $$define_method(name, method) { var $iter = $Module_define_method$31.$$p, block = $iter || nil, $a, $$32, self = this, $case = nil; if ($iter) $Module_define_method$31.$$p = null; if ($iter) $Module_define_method$31.$$p = null;; ; if ($truthy(method === undefined && block === nil)) { self.$raise($$($nesting, 'ArgumentError'), "tried to create a Proc object without a block")}; block = ($truthy($a = block) ? $a : (function() {$case = method; if ($$($nesting, 'Proc')['$===']($case)) {return method} else if ($$($nesting, 'Method')['$===']($case)) {return method.$to_proc().$$unbound} else if ($$($nesting, 'UnboundMethod')['$===']($case)) {return $lambda(($$32 = function($b){var self = $$32.$$s || this, $post_args, args, bound = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; bound = method.$bind(self); return $send(bound, 'call', Opal.to_a(args));}, $$32.$$s = self, $$32.$$arity = -1, $$32))} else {return self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + (block.$class()) + " (expected Proc/Method)")}})()); var id = '$' + name; block.$$jsid = name; block.$$s = null; block.$$def = block; block.$$define_meth = true; Opal.defn(self, id, block); return name; ; }, $Module_define_method$31.$$arity = -2); Opal.def(self, '$remove_method', $Module_remove_method$33 = function $$remove_method($a) { var $post_args, names, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; for (var i = 0, length = names.length; i < length; i++) { Opal.rdef(self, "$" + names[i]); } ; return self; }, $Module_remove_method$33.$$arity = -1); Opal.def(self, '$singleton_class?', $Module_singleton_class$ques$34 = function() { var self = this; return !!self.$$is_singleton; }, $Module_singleton_class$ques$34.$$arity = 0); Opal.def(self, '$include', $Module_include$35 = function $$include($a) { var $post_args, mods, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); mods = $post_args;; for (var i = mods.length - 1; i >= 0; i--) { var mod = mods[i]; if (!mod.$$is_module) { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + ((mod).$class()) + " (expected Module)"); } (mod).$append_features(self); (mod).$included(self); } ; return self; }, $Module_include$35.$$arity = -1); Opal.def(self, '$included_modules', $Module_included_modules$36 = function $$included_modules() { var self = this; return Opal.included_modules(self); }, $Module_included_modules$36.$$arity = 0); Opal.def(self, '$include?', $Module_include$ques$37 = function(mod) { var self = this; if (!mod.$$is_module) { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + ((mod).$class()) + " (expected Module)"); } var i, ii, mod2, ancestors = Opal.ancestors(self); for (i = 0, ii = ancestors.length; i < ii; i++) { mod2 = ancestors[i]; if (mod2 === mod && mod2 !== self) { return true; } } return false; }, $Module_include$ques$37.$$arity = 1); Opal.def(self, '$instance_method', $Module_instance_method$38 = function $$instance_method(name) { var self = this; var meth = self.$$prototype['$' + name]; if (!meth || meth.$$stub) { self.$raise($$($nesting, 'NameError').$new("" + "undefined method `" + (name) + "' for class `" + (self.$name()) + "'", name)); } return $$($nesting, 'UnboundMethod').$new(self, meth.$$owner || self, meth, name); }, $Module_instance_method$38.$$arity = 1); Opal.def(self, '$instance_methods', $Module_instance_methods$39 = function $$instance_methods(include_super) { var self = this; if (include_super == null) { include_super = true; }; if ($truthy(include_super)) { return Opal.instance_methods(self); } else { return Opal.own_instance_methods(self); } ; }, $Module_instance_methods$39.$$arity = -1); Opal.def(self, '$included', $Module_included$40 = function $$included(mod) { var self = this; return nil }, $Module_included$40.$$arity = 1); Opal.def(self, '$extended', $Module_extended$41 = function $$extended(mod) { var self = this; return nil }, $Module_extended$41.$$arity = 1); Opal.def(self, '$extend_object', $Module_extend_object$42 = function $$extend_object(object) { var self = this; return nil }, $Module_extend_object$42.$$arity = 1); Opal.def(self, '$method_added', $Module_method_added$43 = function $$method_added($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $Module_method_added$43.$$arity = -1); Opal.def(self, '$method_removed', $Module_method_removed$44 = function $$method_removed($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $Module_method_removed$44.$$arity = -1); Opal.def(self, '$method_undefined', $Module_method_undefined$45 = function $$method_undefined($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $Module_method_undefined$45.$$arity = -1); Opal.def(self, '$module_eval', $Module_module_eval$46 = function $$module_eval($a) { var $iter = $Module_module_eval$46.$$p, block = $iter || nil, $post_args, args, $b, $$47, self = this, string = nil, file = nil, _lineno = nil, default_eval_options = nil, compiling_options = nil, compiled = nil; if ($iter) $Module_module_eval$46.$$p = null; if ($iter) $Module_module_eval$46.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(($truthy($b = block['$nil?']()) ? !!Opal.compile : $b))) { if ($truthy($range(1, 3, false)['$cover?'](args.$size()))) { } else { $$($nesting, 'Kernel').$raise($$($nesting, 'ArgumentError'), "wrong number of arguments (0 for 1..3)") }; $b = [].concat(Opal.to_a(args)), (string = ($b[0] == null ? nil : $b[0])), (file = ($b[1] == null ? nil : $b[1])), (_lineno = ($b[2] == null ? nil : $b[2])), $b; default_eval_options = $hash2(["file", "eval"], {"file": ($truthy($b = file) ? $b : "(eval)"), "eval": true}); compiling_options = Opal.hash({ arity_check: false }).$merge(default_eval_options); compiled = $$($nesting, 'Opal').$compile(string, compiling_options); block = $send($$($nesting, 'Kernel'), 'proc', [], ($$47 = function(){var self = $$47.$$s || this; return (function(self) { return eval(compiled); })(self) }, $$47.$$s = self, $$47.$$arity = 0, $$47)); } else if ($truthy(args['$any?']())) { $$($nesting, 'Kernel').$raise($$($nesting, 'ArgumentError'), "" + ("" + "wrong number of arguments (" + (args.$size()) + " for 0)") + "\n\n NOTE:If you want to enable passing a String argument please add \"require 'opal-parser'\" to your script\n")}; var old = block.$$s, result; block.$$s = null; result = block.apply(self, [self]); block.$$s = old; return result; ; }, $Module_module_eval$46.$$arity = -1); Opal.alias(self, "class_eval", "module_eval"); Opal.def(self, '$module_exec', $Module_module_exec$48 = function $$module_exec($a) { var $iter = $Module_module_exec$48.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Module_module_exec$48.$$p = null; if ($iter) $Module_module_exec$48.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if (block === nil) { self.$raise($$($nesting, 'LocalJumpError'), "no block given") } var block_self = block.$$s, result; block.$$s = null; result = block.apply(self, args); block.$$s = block_self; return result; ; }, $Module_module_exec$48.$$arity = -1); Opal.alias(self, "class_exec", "module_exec"); Opal.def(self, '$method_defined?', $Module_method_defined$ques$49 = function(method) { var self = this; var body = self.$$prototype['$' + method]; return (!!body) && !body.$$stub; }, $Module_method_defined$ques$49.$$arity = 1); Opal.def(self, '$module_function', $Module_module_function$50 = function $$module_function($a) { var $post_args, methods, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); methods = $post_args;; if (methods.length === 0) { self.$$module_function = true; } else { for (var i = 0, length = methods.length; i < length; i++) { var meth = methods[i], id = '$' + meth, func = self.$$prototype[id]; Opal.defs(self, id, func); } } return self; ; }, $Module_module_function$50.$$arity = -1); Opal.def(self, '$name', $Module_name$51 = function $$name() { var self = this; if (self.$$full_name) { return self.$$full_name; } var result = [], base = self; while (base) { // Give up if any of the ancestors is unnamed if (base.$$name === nil || base.$$name == null) return nil; 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('::'); }, $Module_name$51.$$arity = 0); Opal.def(self, '$prepend', $Module_prepend$52 = function $$prepend($a) { var $post_args, mods, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); mods = $post_args;; if (mods.length === 0) { self.$raise($$($nesting, 'ArgumentError'), "wrong number of arguments (given 0, expected 1+)") } for (var i = mods.length - 1; i >= 0; i--) { var mod = mods[i]; if (!mod.$$is_module) { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + ((mod).$class()) + " (expected Module)"); } (mod).$prepend_features(self); (mod).$prepended(self); } ; return self; }, $Module_prepend$52.$$arity = -1); Opal.def(self, '$prepend_features', $Module_prepend_features$53 = function $$prepend_features(prepender) { var self = this; if (!self.$$is_module) { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + (self.$class()) + " (expected Module)"); } Opal.prepend_features(self, prepender) ; return self; }, $Module_prepend_features$53.$$arity = 1); Opal.def(self, '$prepended', $Module_prepended$54 = function $$prepended(mod) { var self = this; return nil }, $Module_prepended$54.$$arity = 1); Opal.def(self, '$remove_const', $Module_remove_const$55 = function $$remove_const(name) { var self = this; return Opal.const_remove(self, name); }, $Module_remove_const$55.$$arity = 1); Opal.def(self, '$to_s', $Module_to_s$56 = function $$to_s() { var $a, self = this; return ($truthy($a = Opal.Module.$name.call(self)) ? $a : "" + "#<" + (self.$$is_module ? 'Module' : 'Class') + ":0x" + (self.$__id__().$to_s(16)) + ">") }, $Module_to_s$56.$$arity = 0); Opal.def(self, '$undef_method', $Module_undef_method$57 = function $$undef_method($a) { var $post_args, names, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; for (var i = 0, length = names.length; i < length; i++) { Opal.udef(self, "$" + names[i]); } ; return self; }, $Module_undef_method$57.$$arity = -1); Opal.def(self, '$instance_variables', $Module_instance_variables$58 = function $$instance_variables() { var self = this, consts = nil; consts = (Opal.Module.$$nesting = $nesting, self.$constants()); var result = []; for (var name in self) { if (self.hasOwnProperty(name) && name.charAt(0) !== '$' && name !== 'constructor' && !consts['$include?'](name)) { result.push('@' + name); } } return result; ; }, $Module_instance_variables$58.$$arity = 0); Opal.def(self, '$dup', $Module_dup$59 = function $$dup() { var $iter = $Module_dup$59.$$p, $yield = $iter || nil, self = this, copy = nil, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Module_dup$59.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } copy = $send(self, Opal.find_super_dispatcher(self, 'dup', $Module_dup$59, false), $zuper, $iter); copy.$copy_class_variables(self); copy.$copy_constants(self); return copy; }, $Module_dup$59.$$arity = 0); Opal.def(self, '$copy_class_variables', $Module_copy_class_variables$60 = function $$copy_class_variables(other) { var self = this; for (var name in other.$$cvars) { self.$$cvars[name] = other.$$cvars[name]; } }, $Module_copy_class_variables$60.$$arity = 1); return (Opal.def(self, '$copy_constants', $Module_copy_constants$61 = function $$copy_constants(other) { var self = this; var name, other_constants = other.$$const; for (name in other_constants) { Opal.const_set(self, name, other_constants[name]); } }, $Module_copy_constants$61.$$arity = 1), nil) && 'copy_constants'; })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/class"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$require', '$class_eval', '$to_proc', '$initialize_copy', '$allocate', '$name', '$to_s']); self.$require("corelib/module"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Class'); var $nesting = [self].concat($parent_nesting), $Class_new$1, $Class_allocate$2, $Class_inherited$3, $Class_initialize_dup$4, $Class_new$5, $Class_superclass$6, $Class_to_s$7; Opal.defs(self, '$new', $Class_new$1 = function(superclass) { var $iter = $Class_new$1.$$p, block = $iter || nil, self = this; if ($iter) $Class_new$1.$$p = null; if ($iter) $Class_new$1.$$p = null;; if (superclass == null) { superclass = $$($nesting, 'Object'); }; if (!superclass.$$is_class) { throw Opal.TypeError.$new("superclass must be a Class"); } var klass = Opal.allocate_class(nil, superclass); superclass.$inherited(klass); (function() {if ((block !== nil)) { return $send((klass), 'class_eval', [], block.$to_proc()) } else { return nil }; return nil; })() return klass; ; }, $Class_new$1.$$arity = -1); Opal.def(self, '$allocate', $Class_allocate$2 = function $$allocate() { var self = this; var obj = new self.$$constructor(); obj.$$id = Opal.uid(); return obj; }, $Class_allocate$2.$$arity = 0); Opal.def(self, '$inherited', $Class_inherited$3 = function $$inherited(cls) { var self = this; return nil }, $Class_inherited$3.$$arity = 1); Opal.def(self, '$initialize_dup', $Class_initialize_dup$4 = function $$initialize_dup(original) { var self = this; self.$initialize_copy(original); self.$$name = null; self.$$full_name = null; ; }, $Class_initialize_dup$4.$$arity = 1); Opal.def(self, '$new', $Class_new$5 = function($a) { var $iter = $Class_new$5.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Class_new$5.$$p = null; if ($iter) $Class_new$5.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var object = self.$allocate(); Opal.send(object, object.$initialize, args, block); return object; ; }, $Class_new$5.$$arity = -1); Opal.def(self, '$superclass', $Class_superclass$6 = function $$superclass() { var self = this; return self.$$super || nil; }, $Class_superclass$6.$$arity = 0); return (Opal.def(self, '$to_s', $Class_to_s$7 = function $$to_s() { var $iter = $Class_to_s$7.$$p, $yield = $iter || nil, self = this; if ($iter) $Class_to_s$7.$$p = null; var singleton_of = self.$$singleton_of; if (singleton_of && (singleton_of.$$is_a_module)) { return "" + "#"; } else if (singleton_of) { // a singleton class created from an object return "" + "#>"; } return $send(self, Opal.find_super_dispatcher(self, 'to_s', $Class_to_s$7, false), [], null); }, $Class_to_s$7.$$arity = 0), nil) && 'to_s'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/basic_object"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $range = Opal.range, $hash2 = Opal.hash2, $send = Opal.send; Opal.add_stubs(['$==', '$!', '$nil?', '$cover?', '$size', '$raise', '$merge', '$compile', '$proc', '$any?', '$inspect', '$new']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'BasicObject'); var $nesting = [self].concat($parent_nesting), $BasicObject_initialize$1, $BasicObject_$eq_eq$2, $BasicObject_eql$ques$3, $BasicObject___id__$4, $BasicObject___send__$5, $BasicObject_$excl$6, $BasicObject_$not_eq$7, $BasicObject_instance_eval$8, $BasicObject_instance_exec$10, $BasicObject_singleton_method_added$11, $BasicObject_singleton_method_removed$12, $BasicObject_singleton_method_undefined$13, $BasicObject_class$14, $BasicObject_method_missing$15; Opal.def(self, '$initialize', $BasicObject_initialize$1 = function $$initialize($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $BasicObject_initialize$1.$$arity = -1); Opal.def(self, '$==', $BasicObject_$eq_eq$2 = function(other) { var self = this; return self === other; }, $BasicObject_$eq_eq$2.$$arity = 1); Opal.def(self, '$eql?', $BasicObject_eql$ques$3 = function(other) { var self = this; return self['$=='](other) }, $BasicObject_eql$ques$3.$$arity = 1); Opal.alias(self, "equal?", "=="); Opal.def(self, '$__id__', $BasicObject___id__$4 = function $$__id__() { var self = this; if (self.$$id != null) { return self.$$id; } Opal.defineProperty(self, '$$id', Opal.uid()); return self.$$id; }, $BasicObject___id__$4.$$arity = 0); Opal.def(self, '$__send__', $BasicObject___send__$5 = function $$__send__(symbol, $a) { var $iter = $BasicObject___send__$5.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $BasicObject___send__$5.$$p = null; if ($iter) $BasicObject___send__$5.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; 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)); ; }, $BasicObject___send__$5.$$arity = -2); Opal.def(self, '$!', $BasicObject_$excl$6 = function() { var self = this; return false }, $BasicObject_$excl$6.$$arity = 0); Opal.def(self, '$!=', $BasicObject_$not_eq$7 = function(other) { var self = this; return self['$=='](other)['$!']() }, $BasicObject_$not_eq$7.$$arity = 1); Opal.def(self, '$instance_eval', $BasicObject_instance_eval$8 = function $$instance_eval($a) { var $iter = $BasicObject_instance_eval$8.$$p, block = $iter || nil, $post_args, args, $b, $$9, self = this, string = nil, file = nil, _lineno = nil, default_eval_options = nil, compiling_options = nil, compiled = nil; if ($iter) $BasicObject_instance_eval$8.$$p = null; if ($iter) $BasicObject_instance_eval$8.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(($truthy($b = block['$nil?']()) ? !!Opal.compile : $b))) { if ($truthy($range(1, 3, false)['$cover?'](args.$size()))) { } else { $$$('::', 'Kernel').$raise($$$('::', 'ArgumentError'), "wrong number of arguments (0 for 1..3)") }; $b = [].concat(Opal.to_a(args)), (string = ($b[0] == null ? nil : $b[0])), (file = ($b[1] == null ? nil : $b[1])), (_lineno = ($b[2] == null ? nil : $b[2])), $b; default_eval_options = $hash2(["file", "eval"], {"file": ($truthy($b = file) ? $b : "(eval)"), "eval": true}); compiling_options = Opal.hash({ arity_check: false }).$merge(default_eval_options); compiled = $$$('::', 'Opal').$compile(string, compiling_options); block = $send($$$('::', 'Kernel'), 'proc', [], ($$9 = function(){var self = $$9.$$s || this; return (function(self) { return eval(compiled); })(self) }, $$9.$$s = self, $$9.$$arity = 0, $$9)); } else if ($truthy(args['$any?']())) { $$$('::', 'Kernel').$raise($$$('::', 'ArgumentError'), "" + "wrong number of arguments (" + (args.$size()) + " for 0)")}; var old = block.$$s, result; block.$$s = null; // Need to pass $$eval so that method definitions know if this is // being done on a class/module. Cannot be compiler driven since // send(:instance_eval) needs to work. if (self.$$is_a_module) { self.$$eval = true; try { result = block.call(self, self); } finally { self.$$eval = false; } } else { result = block.call(self, self); } block.$$s = old; return result; ; }, $BasicObject_instance_eval$8.$$arity = -1); Opal.def(self, '$instance_exec', $BasicObject_instance_exec$10 = function $$instance_exec($a) { var $iter = $BasicObject_instance_exec$10.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $BasicObject_instance_exec$10.$$p = null; if ($iter) $BasicObject_instance_exec$10.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(block)) { } else { $$$('::', 'Kernel').$raise($$$('::', 'ArgumentError'), "no block given") }; var block_self = block.$$s, result; block.$$s = null; if (self.$$is_a_module) { self.$$eval = true; try { result = block.apply(self, args); } finally { self.$$eval = false; } } else { result = block.apply(self, args); } block.$$s = block_self; return result; ; }, $BasicObject_instance_exec$10.$$arity = -1); Opal.def(self, '$singleton_method_added', $BasicObject_singleton_method_added$11 = function $$singleton_method_added($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $BasicObject_singleton_method_added$11.$$arity = -1); Opal.def(self, '$singleton_method_removed', $BasicObject_singleton_method_removed$12 = function $$singleton_method_removed($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $BasicObject_singleton_method_removed$12.$$arity = -1); Opal.def(self, '$singleton_method_undefined', $BasicObject_singleton_method_undefined$13 = function $$singleton_method_undefined($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $BasicObject_singleton_method_undefined$13.$$arity = -1); Opal.def(self, '$class', $BasicObject_class$14 = function() { var self = this; return self.$$class; }, $BasicObject_class$14.$$arity = 0); return (Opal.def(self, '$method_missing', $BasicObject_method_missing$15 = function $$method_missing(symbol, $a) { var $iter = $BasicObject_method_missing$15.$$p, block = $iter || nil, $post_args, args, self = this, message = nil; if ($iter) $BasicObject_method_missing$15.$$p = null; if ($iter) $BasicObject_method_missing$15.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; message = (function() {if ($truthy(self.$inspect && !self.$inspect.$$stub)) { return "" + "undefined method `" + (symbol) + "' for " + (self.$inspect()) + ":" + (self.$$class) } else { return "" + "undefined method `" + (symbol) + "' for " + (self.$$class) }; return nil; })(); return $$$('::', 'Kernel').$raise($$$('::', 'NoMethodError').$new(message, symbol)); }, $BasicObject_method_missing$15.$$arity = -2), nil) && 'method_missing'; })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/kernel"] = function(Opal) { function $rb_le(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy, $gvars = Opal.gvars, $hash2 = Opal.hash2, $send = Opal.send, $klass = Opal.klass; Opal.add_stubs(['$raise', '$new', '$inspect', '$!', '$=~', '$==', '$object_id', '$class', '$coerce_to?', '$<<', '$allocate', '$copy_instance_variables', '$copy_singleton_methods', '$initialize_clone', '$initialize_copy', '$define_method', '$singleton_class', '$to_proc', '$initialize_dup', '$for', '$empty?', '$pop', '$call', '$coerce_to', '$append_features', '$extend_object', '$extended', '$__id__', '$to_s', '$instance_variable_name!', '$respond_to?', '$to_int', '$coerce_to!', '$Integer', '$nil?', '$===', '$enum_for', '$result', '$any?', '$print', '$format', '$puts', '$each', '$<=', '$length', '$[]', '$exception', '$is_a?', '$rand', '$respond_to_missing?', '$try_convert!', '$expand_path', '$join', '$start_with?', '$new_seed', '$srand', '$sym', '$arg', '$open', '$include']); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_method_missing$1, $Kernel_$eq_tilde$2, $Kernel_$excl_tilde$3, $Kernel_$eq_eq_eq$4, $Kernel_$lt_eq_gt$5, $Kernel_method$6, $Kernel_methods$7, $Kernel_public_methods$8, $Kernel_Array$9, $Kernel_at_exit$10, $Kernel_caller$11, $Kernel_class$12, $Kernel_copy_instance_variables$13, $Kernel_copy_singleton_methods$14, $Kernel_clone$15, $Kernel_initialize_clone$16, $Kernel_define_singleton_method$17, $Kernel_dup$18, $Kernel_initialize_dup$19, $Kernel_enum_for$20, $Kernel_equal$ques$21, $Kernel_exit$22, $Kernel_extend$23, $Kernel_hash$24, $Kernel_initialize_copy$25, $Kernel_inspect$26, $Kernel_instance_of$ques$27, $Kernel_instance_variable_defined$ques$28, $Kernel_instance_variable_get$29, $Kernel_instance_variable_set$30, $Kernel_remove_instance_variable$31, $Kernel_instance_variables$32, $Kernel_Integer$33, $Kernel_Float$34, $Kernel_Hash$35, $Kernel_is_a$ques$36, $Kernel_itself$37, $Kernel_lambda$38, $Kernel_load$39, $Kernel_loop$40, $Kernel_nil$ques$42, $Kernel_printf$43, $Kernel_proc$44, $Kernel_puts$45, $Kernel_p$46, $Kernel_print$48, $Kernel_warn$49, $Kernel_raise$50, $Kernel_rand$51, $Kernel_respond_to$ques$52, $Kernel_respond_to_missing$ques$53, $Kernel_require$54, $Kernel_require_relative$55, $Kernel_require_tree$56, $Kernel_singleton_class$57, $Kernel_sleep$58, $Kernel_srand$59, $Kernel_String$60, $Kernel_tap$61, $Kernel_to_proc$62, $Kernel_to_s$63, $Kernel_catch$64, $Kernel_throw$65, $Kernel_open$66, $Kernel_yield_self$67; Opal.def(self, '$method_missing', $Kernel_method_missing$1 = function $$method_missing(symbol, $a) { var $iter = $Kernel_method_missing$1.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Kernel_method_missing$1.$$p = null; if ($iter) $Kernel_method_missing$1.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; return self.$raise($$($nesting, 'NoMethodError').$new("" + "undefined method `" + (symbol) + "' for " + (self.$inspect()), symbol, args)); }, $Kernel_method_missing$1.$$arity = -2); Opal.def(self, '$=~', $Kernel_$eq_tilde$2 = function(obj) { var self = this; return false }, $Kernel_$eq_tilde$2.$$arity = 1); Opal.def(self, '$!~', $Kernel_$excl_tilde$3 = function(obj) { var self = this; return self['$=~'](obj)['$!']() }, $Kernel_$excl_tilde$3.$$arity = 1); Opal.def(self, '$===', $Kernel_$eq_eq_eq$4 = function(other) { var $a, self = this; return ($truthy($a = self.$object_id()['$=='](other.$object_id())) ? $a : self['$=='](other)) }, $Kernel_$eq_eq_eq$4.$$arity = 1); Opal.def(self, '$<=>', $Kernel_$lt_eq_gt$5 = function(other) { var self = this; // set guard for infinite recursion self.$$comparable = true; var x = self['$=='](other); if (x && x !== nil) { return 0; } return nil; }, $Kernel_$lt_eq_gt$5.$$arity = 1); Opal.def(self, '$method', $Kernel_method$6 = function $$method(name) { var self = this; var meth = self['$' + name]; if (!meth || meth.$$stub) { self.$raise($$($nesting, 'NameError').$new("" + "undefined method `" + (name) + "' for class `" + (self.$class()) + "'", name)); } return $$($nesting, 'Method').$new(self, meth.$$owner || self.$class(), meth, name); }, $Kernel_method$6.$$arity = 1); Opal.def(self, '$methods', $Kernel_methods$7 = function $$methods(all) { var self = this; if (all == null) { all = true; }; if ($truthy(all)) { return Opal.methods(self); } else { return Opal.own_methods(self); } ; }, $Kernel_methods$7.$$arity = -1); Opal.def(self, '$public_methods', $Kernel_public_methods$8 = function $$public_methods(all) { var self = this; if (all == null) { all = true; }; if ($truthy(all)) { return Opal.methods(self); } else { return Opal.receiver_methods(self); } ; }, $Kernel_public_methods$8.$$arity = -1); Opal.def(self, '$Array', $Kernel_Array$9 = function $$Array(object) { var self = this; var coerced; if (object === nil) { return []; } if (object.$$is_array) { return object; } coerced = $$($nesting, 'Opal')['$coerce_to?'](object, $$($nesting, 'Array'), "to_ary"); if (coerced !== nil) { return coerced; } coerced = $$($nesting, 'Opal')['$coerce_to?'](object, $$($nesting, 'Array'), "to_a"); if (coerced !== nil) { return coerced; } return [object]; }, $Kernel_Array$9.$$arity = 1); Opal.def(self, '$at_exit', $Kernel_at_exit$10 = function $$at_exit() { var $iter = $Kernel_at_exit$10.$$p, block = $iter || nil, $a, self = this; if ($gvars.__at_exit__ == null) $gvars.__at_exit__ = nil; if ($iter) $Kernel_at_exit$10.$$p = null; if ($iter) $Kernel_at_exit$10.$$p = null;; $gvars.__at_exit__ = ($truthy($a = $gvars.__at_exit__) ? $a : []); return $gvars.__at_exit__['$<<'](block); }, $Kernel_at_exit$10.$$arity = 0); Opal.def(self, '$caller', $Kernel_caller$11 = function $$caller($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return []; }, $Kernel_caller$11.$$arity = -1); Opal.def(self, '$class', $Kernel_class$12 = function() { var self = this; return self.$$class; }, $Kernel_class$12.$$arity = 0); Opal.def(self, '$copy_instance_variables', $Kernel_copy_instance_variables$13 = function $$copy_instance_variables(other) { var self = this; var keys = Object.keys(other), i, ii, name; for (i = 0, ii = keys.length; i < ii; i++) { name = keys[i]; if (name.charAt(0) !== '$' && other.hasOwnProperty(name)) { self[name] = other[name]; } } }, $Kernel_copy_instance_variables$13.$$arity = 1); Opal.def(self, '$copy_singleton_methods', $Kernel_copy_singleton_methods$14 = function $$copy_singleton_methods(other) { var self = this; var i, name, names, length; if (other.hasOwnProperty('$$meta')) { var other_singleton_class = Opal.get_singleton_class(other); var self_singleton_class = Opal.get_singleton_class(self); names = Object.getOwnPropertyNames(other_singleton_class.$$prototype); for (i = 0, length = names.length; i < length; i++) { name = names[i]; if (Opal.is_method(name)) { self_singleton_class.$$prototype[name] = other_singleton_class.$$prototype[name]; } } self_singleton_class.$$const = Object.assign({}, other_singleton_class.$$const); Object.setPrototypeOf( self_singleton_class.$$prototype, Object.getPrototypeOf(other_singleton_class.$$prototype) ); } for (i = 0, names = Object.getOwnPropertyNames(other), length = names.length; i < length; i++) { name = names[i]; if (name.charAt(0) === '$' && name.charAt(1) !== '$' && other.hasOwnProperty(name)) { self[name] = other[name]; } } }, $Kernel_copy_singleton_methods$14.$$arity = 1); Opal.def(self, '$clone', $Kernel_clone$15 = function $$clone($kwargs) { var freeze, self = this, copy = nil; if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; freeze = $kwargs.$$smap["freeze"]; if (freeze == null) { freeze = true }; copy = self.$class().$allocate(); copy.$copy_instance_variables(self); copy.$copy_singleton_methods(self); copy.$initialize_clone(self); return copy; }, $Kernel_clone$15.$$arity = -1); Opal.def(self, '$initialize_clone', $Kernel_initialize_clone$16 = function $$initialize_clone(other) { var self = this; return self.$initialize_copy(other) }, $Kernel_initialize_clone$16.$$arity = 1); Opal.def(self, '$define_singleton_method', $Kernel_define_singleton_method$17 = function $$define_singleton_method(name, method) { var $iter = $Kernel_define_singleton_method$17.$$p, block = $iter || nil, self = this; if ($iter) $Kernel_define_singleton_method$17.$$p = null; if ($iter) $Kernel_define_singleton_method$17.$$p = null;; ; return $send(self.$singleton_class(), 'define_method', [name, method], block.$to_proc()); }, $Kernel_define_singleton_method$17.$$arity = -2); Opal.def(self, '$dup', $Kernel_dup$18 = function $$dup() { var self = this, copy = nil; copy = self.$class().$allocate(); copy.$copy_instance_variables(self); copy.$initialize_dup(self); return copy; }, $Kernel_dup$18.$$arity = 0); Opal.def(self, '$initialize_dup', $Kernel_initialize_dup$19 = function $$initialize_dup(other) { var self = this; return self.$initialize_copy(other) }, $Kernel_initialize_dup$19.$$arity = 1); Opal.def(self, '$enum_for', $Kernel_enum_for$20 = function $$enum_for($a, $b) { var $iter = $Kernel_enum_for$20.$$p, block = $iter || nil, $post_args, method, args, self = this; if ($iter) $Kernel_enum_for$20.$$p = null; if ($iter) $Kernel_enum_for$20.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); if ($post_args.length > 0) { method = $post_args[0]; $post_args.splice(0, 1); } if (method == null) { method = "each"; }; args = $post_args;; return $send($$($nesting, 'Enumerator'), 'for', [self, method].concat(Opal.to_a(args)), block.$to_proc()); }, $Kernel_enum_for$20.$$arity = -1); Opal.alias(self, "to_enum", "enum_for"); Opal.def(self, '$equal?', $Kernel_equal$ques$21 = function(other) { var self = this; return self === other; }, $Kernel_equal$ques$21.$$arity = 1); Opal.def(self, '$exit', $Kernel_exit$22 = function $$exit(status) { var $a, self = this, block = nil; if ($gvars.__at_exit__ == null) $gvars.__at_exit__ = nil; if (status == null) { status = true; }; $gvars.__at_exit__ = ($truthy($a = $gvars.__at_exit__) ? $a : []); while (!($truthy($gvars.__at_exit__['$empty?']()))) { block = $gvars.__at_exit__.$pop(); block.$call(); }; if (status.$$is_boolean) { status = status ? 0 : 1; } else { status = $$($nesting, 'Opal').$coerce_to(status, $$($nesting, 'Integer'), "to_int") } Opal.exit(status); ; return nil; }, $Kernel_exit$22.$$arity = -1); Opal.def(self, '$extend', $Kernel_extend$23 = function $$extend($a) { var $post_args, mods, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); mods = $post_args;; var singleton = self.$singleton_class(); for (var i = mods.length - 1; i >= 0; i--) { var mod = mods[i]; if (!mod.$$is_module) { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + ((mod).$class()) + " (expected Module)"); } (mod).$append_features(singleton); (mod).$extend_object(self); (mod).$extended(self); } ; return self; }, $Kernel_extend$23.$$arity = -1); Opal.def(self, '$hash', $Kernel_hash$24 = function $$hash() { var self = this; return self.$__id__() }, $Kernel_hash$24.$$arity = 0); Opal.def(self, '$initialize_copy', $Kernel_initialize_copy$25 = function $$initialize_copy(other) { var self = this; return nil }, $Kernel_initialize_copy$25.$$arity = 1); Opal.def(self, '$inspect', $Kernel_inspect$26 = function $$inspect() { var self = this; return self.$to_s() }, $Kernel_inspect$26.$$arity = 0); Opal.def(self, '$instance_of?', $Kernel_instance_of$ques$27 = function(klass) { var self = this; if (!klass.$$is_class && !klass.$$is_module) { self.$raise($$($nesting, 'TypeError'), "class or module required"); } return self.$$class === klass; }, $Kernel_instance_of$ques$27.$$arity = 1); Opal.def(self, '$instance_variable_defined?', $Kernel_instance_variable_defined$ques$28 = function(name) { var self = this; name = $$($nesting, 'Opal')['$instance_variable_name!'](name); return Opal.hasOwnProperty.call(self, name.substr(1));; }, $Kernel_instance_variable_defined$ques$28.$$arity = 1); Opal.def(self, '$instance_variable_get', $Kernel_instance_variable_get$29 = function $$instance_variable_get(name) { var self = this; name = $$($nesting, 'Opal')['$instance_variable_name!'](name); var ivar = self[Opal.ivar(name.substr(1))]; return ivar == null ? nil : ivar; ; }, $Kernel_instance_variable_get$29.$$arity = 1); Opal.def(self, '$instance_variable_set', $Kernel_instance_variable_set$30 = function $$instance_variable_set(name, value) { var self = this; name = $$($nesting, 'Opal')['$instance_variable_name!'](name); return self[Opal.ivar(name.substr(1))] = value;; }, $Kernel_instance_variable_set$30.$$arity = 2); Opal.def(self, '$remove_instance_variable', $Kernel_remove_instance_variable$31 = function $$remove_instance_variable(name) { var self = this; name = $$($nesting, 'Opal')['$instance_variable_name!'](name); var key = Opal.ivar(name.substr(1)), val; if (self.hasOwnProperty(key)) { val = self[key]; delete self[key]; return val; } ; return self.$raise($$($nesting, 'NameError'), "" + "instance variable " + (name) + " not defined"); }, $Kernel_remove_instance_variable$31.$$arity = 1); Opal.def(self, '$instance_variables', $Kernel_instance_variables$32 = function $$instance_variables() { var self = this; var result = [], ivar; for (var name in self) { if (self.hasOwnProperty(name) && name.charAt(0) !== '$') { if (name.substr(-1) === '$') { ivar = name.slice(0, name.length - 1); } else { ivar = name; } result.push('@' + ivar); } } return result; }, $Kernel_instance_variables$32.$$arity = 0); Opal.def(self, '$Integer', $Kernel_Integer$33 = function $$Integer(value, base) { var self = this; ; var i, str, base_digits; if (!value.$$is_string) { if (base !== undefined) { self.$raise($$($nesting, 'ArgumentError'), "base specified for non string value") } if (value === nil) { self.$raise($$($nesting, 'TypeError'), "can't convert nil into Integer") } if (value.$$is_number) { if (value === Infinity || value === -Infinity || isNaN(value)) { self.$raise($$($nesting, 'FloatDomainError'), value) } return Math.floor(value); } if (value['$respond_to?']("to_int")) { i = value.$to_int(); if (i !== nil) { return i; } } return $$($nesting, 'Opal')['$coerce_to!'](value, $$($nesting, 'Integer'), "to_i"); } if (value === "0") { return 0; } if (base === undefined) { base = 0; } else { base = $$($nesting, 'Opal').$coerce_to(base, $$($nesting, 'Integer'), "to_int"); if (base === 1 || base < 0 || base > 36) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid radix " + (base)) } } str = value.toLowerCase(); str = str.replace(/(\d)_(?=\d)/g, '$1'); str = str.replace(/^(\s*[+-]?)(0[bodx]?)/, function (_, head, flag) { switch (flag) { case '0b': if (base === 0 || base === 2) { base = 2; return head; } case '0': case '0o': if (base === 0 || base === 8) { base = 8; return head; } case '0d': if (base === 0 || base === 10) { base = 10; return head; } case '0x': if (base === 0 || base === 16) { base = 16; return head; } } self.$raise($$($nesting, 'ArgumentError'), "" + "invalid value for Integer(): \"" + (value) + "\"") }); base = (base === 0 ? 10 : base); base_digits = '0-' + (base <= 10 ? base - 1 : '9a-' + String.fromCharCode(97 + (base - 11))); if (!(new RegExp('^\\s*[+-]?[' + base_digits + ']+\\s*$')).test(str)) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid value for Integer(): \"" + (value) + "\"") } i = parseInt(str, base); if (isNaN(i)) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid value for Integer(): \"" + (value) + "\"") } return i; ; }, $Kernel_Integer$33.$$arity = -2); Opal.def(self, '$Float', $Kernel_Float$34 = function $$Float(value) { var self = this; var str; if (value === nil) { self.$raise($$($nesting, 'TypeError'), "can't convert nil into Float") } if (value.$$is_string) { str = value.toString(); str = str.replace(/(\d)_(?=\d)/g, '$1'); //Special case for hex strings only: if (/^\s*[-+]?0[xX][0-9a-fA-F]+\s*$/.test(str)) { return self.$Integer(str); } if (!/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/.test(str)) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid value for Float(): \"" + (value) + "\"") } return parseFloat(str); } return $$($nesting, 'Opal')['$coerce_to!'](value, $$($nesting, 'Float'), "to_f"); }, $Kernel_Float$34.$$arity = 1); Opal.def(self, '$Hash', $Kernel_Hash$35 = function $$Hash(arg) { var $a, self = this; if ($truthy(($truthy($a = arg['$nil?']()) ? $a : arg['$==']([])))) { return $hash2([], {})}; if ($truthy($$($nesting, 'Hash')['$==='](arg))) { return arg}; return $$($nesting, 'Opal')['$coerce_to!'](arg, $$($nesting, 'Hash'), "to_hash"); }, $Kernel_Hash$35.$$arity = 1); Opal.def(self, '$is_a?', $Kernel_is_a$ques$36 = function(klass) { var self = this; if (!klass.$$is_class && !klass.$$is_module) { self.$raise($$($nesting, 'TypeError'), "class or module required"); } return Opal.is_a(self, klass); }, $Kernel_is_a$ques$36.$$arity = 1); Opal.def(self, '$itself', $Kernel_itself$37 = function $$itself() { var self = this; return self }, $Kernel_itself$37.$$arity = 0); Opal.alias(self, "kind_of?", "is_a?"); Opal.def(self, '$lambda', $Kernel_lambda$38 = function $$lambda() { var $iter = $Kernel_lambda$38.$$p, block = $iter || nil, self = this; if ($iter) $Kernel_lambda$38.$$p = null; if ($iter) $Kernel_lambda$38.$$p = null;; return Opal.lambda(block);; }, $Kernel_lambda$38.$$arity = 0); Opal.def(self, '$load', $Kernel_load$39 = function $$load(file) { var self = this; file = $$($nesting, 'Opal')['$coerce_to!'](file, $$($nesting, 'String'), "to_str"); return Opal.load(file); }, $Kernel_load$39.$$arity = 1); Opal.def(self, '$loop', $Kernel_loop$40 = function $$loop() { var $$41, $a, $iter = $Kernel_loop$40.$$p, $yield = $iter || nil, self = this, e = nil; if ($iter) $Kernel_loop$40.$$p = null; if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["loop"], ($$41 = function(){var self = $$41.$$s || this; return $$$($$($nesting, 'Float'), 'INFINITY')}, $$41.$$s = self, $$41.$$arity = 0, $$41)) }; while ($truthy(true)) { try { Opal.yieldX($yield, []) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StopIteration')])) {e = $err; try { return e.$result() } finally { Opal.pop_exception() } } else { throw $err; } }; }; return self; }, $Kernel_loop$40.$$arity = 0); Opal.def(self, '$nil?', $Kernel_nil$ques$42 = function() { var self = this; return false }, $Kernel_nil$ques$42.$$arity = 0); Opal.alias(self, "object_id", "__id__"); Opal.def(self, '$printf', $Kernel_printf$43 = function $$printf($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(args['$any?']())) { self.$print($send(self, 'format', Opal.to_a(args)))}; return nil; }, $Kernel_printf$43.$$arity = -1); Opal.def(self, '$proc', $Kernel_proc$44 = function $$proc() { var $iter = $Kernel_proc$44.$$p, block = $iter || nil, self = this; if ($iter) $Kernel_proc$44.$$p = null; if ($iter) $Kernel_proc$44.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to create Proc object without a block") }; block.$$is_lambda = false; return block; }, $Kernel_proc$44.$$arity = 0); Opal.def(self, '$puts', $Kernel_puts$45 = function $$puts($a) { var $post_args, strs, self = this; if ($gvars.stdout == null) $gvars.stdout = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); strs = $post_args;; return $send($gvars.stdout, 'puts', Opal.to_a(strs)); }, $Kernel_puts$45.$$arity = -1); Opal.def(self, '$p', $Kernel_p$46 = function $$p($a) { var $post_args, args, $$47, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; $send(args, 'each', [], ($$47 = function(obj){var self = $$47.$$s || this; if ($gvars.stdout == null) $gvars.stdout = nil; if (obj == null) { obj = nil; }; return $gvars.stdout.$puts(obj.$inspect());}, $$47.$$s = self, $$47.$$arity = 1, $$47)); if ($truthy($rb_le(args.$length(), 1))) { return args['$[]'](0) } else { return args }; }, $Kernel_p$46.$$arity = -1); Opal.def(self, '$print', $Kernel_print$48 = function $$print($a) { var $post_args, strs, self = this; if ($gvars.stdout == null) $gvars.stdout = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); strs = $post_args;; return $send($gvars.stdout, 'print', Opal.to_a(strs)); }, $Kernel_print$48.$$arity = -1); Opal.def(self, '$warn', $Kernel_warn$49 = function $$warn($a) { var $post_args, strs, $b, self = this; if ($gvars.VERBOSE == null) $gvars.VERBOSE = nil; if ($gvars.stderr == null) $gvars.stderr = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); strs = $post_args;; if ($truthy(($truthy($b = $gvars.VERBOSE['$nil?']()) ? $b : strs['$empty?']()))) { return nil } else { return $send($gvars.stderr, 'puts', Opal.to_a(strs)) }; }, $Kernel_warn$49.$$arity = -1); Opal.def(self, '$raise', $Kernel_raise$50 = function $$raise(exception, string, _backtrace) { var self = this; if ($gvars["!"] == null) $gvars["!"] = nil; ; if (string == null) { string = nil; }; if (_backtrace == null) { _backtrace = nil; }; if (exception == null && $gvars["!"] !== nil) { throw $gvars["!"]; } if (exception == null) { exception = $$($nesting, 'RuntimeError').$new(); } else if (exception.$$is_string) { exception = $$($nesting, 'RuntimeError').$new(exception); } // using respond_to? and not an undefined check to avoid method_missing matching as true else if (exception.$$is_class && exception['$respond_to?']("exception")) { exception = exception.$exception(string); } else if (exception['$is_a?']($$($nesting, 'Exception'))) { // exception is fine } else { exception = $$($nesting, 'TypeError').$new("exception class/object expected"); } if ($gvars["!"] !== nil) { Opal.exceptions.push($gvars["!"]); } $gvars["!"] = exception; throw exception; ; }, $Kernel_raise$50.$$arity = -1); Opal.alias(self, "fail", "raise"); Opal.def(self, '$rand', $Kernel_rand$51 = function $$rand(max) { var self = this; ; if (max === undefined) { return $$$($$($nesting, 'Random'), 'DEFAULT').$rand(); } if (max.$$is_number) { if (max < 0) { max = Math.abs(max); } if (max % 1 !== 0) { max = max.$to_i(); } if (max === 0) { max = undefined; } } ; return $$$($$($nesting, 'Random'), 'DEFAULT').$rand(max); }, $Kernel_rand$51.$$arity = -1); Opal.def(self, '$respond_to?', $Kernel_respond_to$ques$52 = function(name, include_all) { var self = this; if (include_all == null) { include_all = false; }; if ($truthy(self['$respond_to_missing?'](name, include_all))) { return true}; var body = self['$' + name]; if (typeof(body) === "function" && !body.$$stub) { return true; } ; return false; }, $Kernel_respond_to$ques$52.$$arity = -2); Opal.def(self, '$respond_to_missing?', $Kernel_respond_to_missing$ques$53 = function(method_name, include_all) { var self = this; if (include_all == null) { include_all = false; }; return false; }, $Kernel_respond_to_missing$ques$53.$$arity = -2); Opal.def(self, '$require', $Kernel_require$54 = function $$require(file) { var self = this; file = $$($nesting, 'Opal')['$coerce_to!'](file, $$($nesting, 'String'), "to_str"); return Opal.require(file); }, $Kernel_require$54.$$arity = 1); Opal.def(self, '$require_relative', $Kernel_require_relative$55 = function $$require_relative(file) { var self = this; $$($nesting, 'Opal')['$try_convert!'](file, $$($nesting, 'String'), "to_str"); file = $$($nesting, 'File').$expand_path($$($nesting, 'File').$join(Opal.current_file, "..", file)); return Opal.require(file); }, $Kernel_require_relative$55.$$arity = 1); Opal.def(self, '$require_tree', $Kernel_require_tree$56 = function $$require_tree(path) { var self = this; var result = []; path = $$($nesting, 'File').$expand_path(path) path = Opal.normalize(path); if (path === '.') path = ''; for (var name in Opal.modules) { if ((name)['$start_with?'](path)) { result.push([name, Opal.require(name)]); } } return result; }, $Kernel_require_tree$56.$$arity = 1); Opal.alias(self, "send", "__send__"); Opal.alias(self, "public_send", "__send__"); Opal.def(self, '$singleton_class', $Kernel_singleton_class$57 = function $$singleton_class() { var self = this; return Opal.get_singleton_class(self); }, $Kernel_singleton_class$57.$$arity = 0); Opal.def(self, '$sleep', $Kernel_sleep$58 = function $$sleep(seconds) { var self = this; if (seconds == null) { seconds = nil; }; if (seconds === nil) { self.$raise($$($nesting, 'TypeError'), "can't convert NilClass into time interval") } if (!seconds.$$is_number) { self.$raise($$($nesting, 'TypeError'), "" + "can't convert " + (seconds.$class()) + " into time interval") } if (seconds < 0) { self.$raise($$($nesting, 'ArgumentError'), "time interval must be positive") } var get_time = Opal.global.performance ? function() {return performance.now()} : function() {return new Date()} var t = get_time(); while (get_time() - t <= seconds * 1000); return seconds; ; }, $Kernel_sleep$58.$$arity = -1); Opal.def(self, '$srand', $Kernel_srand$59 = function $$srand(seed) { var self = this; if (seed == null) { seed = $$($nesting, 'Random').$new_seed(); }; return $$($nesting, 'Random').$srand(seed); }, $Kernel_srand$59.$$arity = -1); Opal.def(self, '$String', $Kernel_String$60 = function $$String(str) { var $a, self = this; return ($truthy($a = $$($nesting, 'Opal')['$coerce_to?'](str, $$($nesting, 'String'), "to_str")) ? $a : $$($nesting, 'Opal')['$coerce_to!'](str, $$($nesting, 'String'), "to_s")) }, $Kernel_String$60.$$arity = 1); Opal.def(self, '$tap', $Kernel_tap$61 = function $$tap() { var $iter = $Kernel_tap$61.$$p, block = $iter || nil, self = this; if ($iter) $Kernel_tap$61.$$p = null; if ($iter) $Kernel_tap$61.$$p = null;; Opal.yield1(block, self); return self; }, $Kernel_tap$61.$$arity = 0); Opal.def(self, '$to_proc', $Kernel_to_proc$62 = function $$to_proc() { var self = this; return self }, $Kernel_to_proc$62.$$arity = 0); Opal.def(self, '$to_s', $Kernel_to_s$63 = function $$to_s() { var self = this; return "" + "#<" + (self.$class()) + ":0x" + (self.$__id__().$to_s(16)) + ">" }, $Kernel_to_s$63.$$arity = 0); Opal.def(self, '$catch', $Kernel_catch$64 = function(sym) { var $iter = $Kernel_catch$64.$$p, $yield = $iter || nil, self = this, e = nil; if ($iter) $Kernel_catch$64.$$p = null; try { return Opal.yieldX($yield, []); } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'UncaughtThrowError')])) {e = $err; try { if (e.$sym()['$=='](sym)) { return e.$arg()}; return self.$raise(); } finally { Opal.pop_exception() } } else { throw $err; } } }, $Kernel_catch$64.$$arity = 1); Opal.def(self, '$throw', $Kernel_throw$65 = function($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return self.$raise($$($nesting, 'UncaughtThrowError'), args); }, $Kernel_throw$65.$$arity = -1); Opal.def(self, '$open', $Kernel_open$66 = function $$open($a) { var $iter = $Kernel_open$66.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Kernel_open$66.$$p = null; if ($iter) $Kernel_open$66.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send($$($nesting, 'File'), 'open', Opal.to_a(args), block.$to_proc()); }, $Kernel_open$66.$$arity = -1); Opal.def(self, '$yield_self', $Kernel_yield_self$67 = function $$yield_self() { var $$68, $iter = $Kernel_yield_self$67.$$p, $yield = $iter || nil, self = this; if ($iter) $Kernel_yield_self$67.$$p = null; if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["yield_self"], ($$68 = function(){var self = $$68.$$s || this; return 1}, $$68.$$s = self, $$68.$$arity = 0, $$68)) }; return Opal.yield1($yield, self);; }, $Kernel_yield_self$67.$$arity = 0); })($nesting[0], $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Object'); var $nesting = [self].concat($parent_nesting); return self.$include($$($nesting, 'Kernel')) })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/error"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $module = Opal.module, $hash2 = Opal.hash2; Opal.add_stubs(['$new', '$clone', '$to_s', '$empty?', '$class', '$raise', '$+', '$attr_reader', '$[]', '$>', '$length', '$inspect']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Exception'); var $nesting = [self].concat($parent_nesting), $Exception_new$1, $Exception_exception$2, $Exception_initialize$3, $Exception_backtrace$4, $Exception_exception$5, $Exception_message$6, $Exception_inspect$7, $Exception_set_backtrace$8, $Exception_to_s$9; self.$$prototype.message = nil; var stack_trace_limit; Opal.defs(self, '$new', $Exception_new$1 = function($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var message = (args.length > 0) ? args[0] : nil; var error = new self.$$constructor(message); error.name = self.$$name; error.message = message; Opal.send(error, error.$initialize, args); // Error.captureStackTrace() will use .name and .toString to build the // first line of the stack trace so it must be called after the error // has been initialized. // https://nodejs.org/dist/latest-v6.x/docs/api/errors.html if (Opal.config.enable_stack_trace && Error.captureStackTrace) { // Passing Kernel.raise will cut the stack trace from that point above Error.captureStackTrace(error, stack_trace_limit); } return error; ; }, $Exception_new$1.$$arity = -1); stack_trace_limit = self.$new; Opal.defs(self, '$exception', $Exception_exception$2 = function $$exception($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self, 'new', Opal.to_a(args)); }, $Exception_exception$2.$$arity = -1); Opal.def(self, '$initialize', $Exception_initialize$3 = function $$initialize($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return self.message = (args.length > 0) ? args[0] : nil;; }, $Exception_initialize$3.$$arity = -1); Opal.def(self, '$backtrace', $Exception_backtrace$4 = function $$backtrace() { var self = this; if (self.backtrace) { // nil is a valid backtrace return self.backtrace; } var backtrace = self.stack; if (typeof(backtrace) === 'string') { return backtrace.split("\n").slice(0, 15); } else if (backtrace) { return backtrace.slice(0, 15); } return []; }, $Exception_backtrace$4.$$arity = 0); Opal.def(self, '$exception', $Exception_exception$5 = function $$exception(str) { var self = this; if (str == null) { str = nil; }; if (str === nil || self === str) { return self; } var cloned = self.$clone(); cloned.message = str; cloned.stack = self.stack; return cloned; ; }, $Exception_exception$5.$$arity = -1); Opal.def(self, '$message', $Exception_message$6 = function $$message() { var self = this; return self.$to_s() }, $Exception_message$6.$$arity = 0); Opal.def(self, '$inspect', $Exception_inspect$7 = function $$inspect() { var self = this, as_str = nil; as_str = self.$to_s(); if ($truthy(as_str['$empty?']())) { return self.$class().$to_s() } else { return "" + "#<" + (self.$class().$to_s()) + ": " + (self.$to_s()) + ">" }; }, $Exception_inspect$7.$$arity = 0); Opal.def(self, '$set_backtrace', $Exception_set_backtrace$8 = function $$set_backtrace(backtrace) { var self = this; var valid = true, i, ii; if (backtrace === nil) { self.backtrace = nil; self.stack = ''; } else if (backtrace.$$is_string) { self.backtrace = [backtrace]; self.stack = backtrace; } else { if (backtrace.$$is_array) { for (i = 0, ii = backtrace.length; i < ii; i++) { if (!backtrace[i].$$is_string) { valid = false; break; } } } else { valid = false; } if (valid === false) { self.$raise($$($nesting, 'TypeError'), "backtrace must be Array of String") } self.backtrace = backtrace; self.stack = backtrace.join('\n'); } return backtrace; }, $Exception_set_backtrace$8.$$arity = 1); return (Opal.def(self, '$to_s', $Exception_to_s$9 = function $$to_s() { var $a, $b, self = this; return ($truthy($a = ($truthy($b = self.message) ? self.message.$to_s() : $b)) ? $a : self.$class().$to_s()) }, $Exception_to_s$9.$$arity = 0), nil) && 'to_s'; })($nesting[0], Error, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'ScriptError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'SyntaxError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'ScriptError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'LoadError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'ScriptError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NotImplementedError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'ScriptError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'SystemExit'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NoMemoryError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'SignalException'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Interrupt'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'SecurityError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'StandardError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'EncodingError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'ZeroDivisionError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NameError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NoMethodError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'NameError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'RuntimeError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'FrozenError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'RuntimeError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'LocalJumpError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'TypeError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'ArgumentError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'IndexError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'StopIteration'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'IndexError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'KeyError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'IndexError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'RangeError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'FloatDomainError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'RangeError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'IOError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'SystemCallError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Errno'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'EINVAL'); var $nesting = [self].concat($parent_nesting), $EINVAL_new$10; return (Opal.defs(self, '$new', $EINVAL_new$10 = function(name) { var $iter = $EINVAL_new$10.$$p, $yield = $iter || nil, self = this, message = nil; if ($iter) $EINVAL_new$10.$$p = null; if (name == null) { name = nil; }; message = "Invalid argument"; if ($truthy(name)) { message = $rb_plus(message, "" + " - " + (name))}; return $send(self, Opal.find_super_dispatcher(self, 'new', $EINVAL_new$10, false, self.$$class.$$prototype), [message], null); }, $EINVAL_new$10.$$arity = -1), nil) && 'new' })($nesting[0], $$($nesting, 'SystemCallError'), $nesting) })($nesting[0], $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'UncaughtThrowError'); var $nesting = [self].concat($parent_nesting), $UncaughtThrowError_initialize$11; self.$$prototype.sym = nil; self.$attr_reader("sym", "arg"); return (Opal.def(self, '$initialize', $UncaughtThrowError_initialize$11 = function $$initialize(args) { var $iter = $UncaughtThrowError_initialize$11.$$p, $yield = $iter || nil, self = this; if ($iter) $UncaughtThrowError_initialize$11.$$p = null; self.sym = args['$[]'](0); if ($truthy($rb_gt(args.$length(), 1))) { self.arg = args['$[]'](1)}; return $send(self, Opal.find_super_dispatcher(self, 'initialize', $UncaughtThrowError_initialize$11, false), ["" + "uncaught throw " + (self.sym.$inspect())], null); }, $UncaughtThrowError_initialize$11.$$arity = 1), nil) && 'initialize'; })($nesting[0], $$($nesting, 'ArgumentError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NameError'); var $nesting = [self].concat($parent_nesting), $NameError_initialize$12; self.$attr_reader("name"); return (Opal.def(self, '$initialize', $NameError_initialize$12 = function $$initialize(message, name) { var $iter = $NameError_initialize$12.$$p, $yield = $iter || nil, self = this; if ($iter) $NameError_initialize$12.$$p = null; if (name == null) { name = nil; }; $send(self, Opal.find_super_dispatcher(self, 'initialize', $NameError_initialize$12, false), [message], null); return (self.name = name); }, $NameError_initialize$12.$$arity = -2), nil) && 'initialize'; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NoMethodError'); var $nesting = [self].concat($parent_nesting), $NoMethodError_initialize$13; self.$attr_reader("args"); return (Opal.def(self, '$initialize', $NoMethodError_initialize$13 = function $$initialize(message, name, args) { var $iter = $NoMethodError_initialize$13.$$p, $yield = $iter || nil, self = this; if ($iter) $NoMethodError_initialize$13.$$p = null; if (name == null) { name = nil; }; if (args == null) { args = []; }; $send(self, Opal.find_super_dispatcher(self, 'initialize', $NoMethodError_initialize$13, false), [message, name], null); return (self.args = args); }, $NoMethodError_initialize$13.$$arity = -2), nil) && 'initialize'; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'StopIteration'); var $nesting = [self].concat($parent_nesting); return self.$attr_reader("result") })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'KeyError'); var $nesting = [self].concat($parent_nesting), $KeyError_initialize$14, $KeyError_receiver$15, $KeyError_key$16; self.$$prototype.receiver = self.$$prototype.key = nil; Opal.def(self, '$initialize', $KeyError_initialize$14 = function $$initialize(message, $kwargs) { var receiver, key, $iter = $KeyError_initialize$14.$$p, $yield = $iter || nil, self = this; if ($iter) $KeyError_initialize$14.$$p = null; if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; receiver = $kwargs.$$smap["receiver"]; if (receiver == null) { receiver = nil }; key = $kwargs.$$smap["key"]; if (key == null) { key = nil }; $send(self, Opal.find_super_dispatcher(self, 'initialize', $KeyError_initialize$14, false), [message], null); self.receiver = receiver; return (self.key = key); }, $KeyError_initialize$14.$$arity = -2); Opal.def(self, '$receiver', $KeyError_receiver$15 = function $$receiver() { var $a, self = this; return ($truthy($a = self.receiver) ? $a : self.$raise($$($nesting, 'ArgumentError'), "no receiver is available")) }, $KeyError_receiver$15.$$arity = 0); return (Opal.def(self, '$key', $KeyError_key$16 = function $$key() { var $a, self = this; return ($truthy($a = self.key) ? $a : self.$raise($$($nesting, 'ArgumentError'), "no key is available")) }, $KeyError_key$16.$$arity = 0), nil) && 'key'; })($nesting[0], null, $nesting); return (function($base, $parent_nesting) { var self = $module($base, 'JS'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Error'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], null, $nesting) })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/constants"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice; Opal.const_set($nesting[0], 'RUBY_PLATFORM', "opal"); Opal.const_set($nesting[0], 'RUBY_ENGINE', "opal"); Opal.const_set($nesting[0], 'RUBY_VERSION', "2.5.7"); Opal.const_set($nesting[0], 'RUBY_ENGINE_VERSION', "1.0.3"); Opal.const_set($nesting[0], 'RUBY_RELEASE_DATE', "2020-02-01"); Opal.const_set($nesting[0], 'RUBY_PATCHLEVEL', 0); Opal.const_set($nesting[0], 'RUBY_REVISION', 0); Opal.const_set($nesting[0], 'RUBY_COPYRIGHT', "opal - Copyright (C) 2013-2020 Adam Beynon and the Opal contributors"); return Opal.const_set($nesting[0], 'RUBY_DESCRIPTION', "" + "opal " + ($$($nesting, 'RUBY_ENGINE_VERSION')) + " (" + ($$($nesting, 'RUBY_RELEASE_DATE')) + " revision " + ($$($nesting, 'RUBY_REVISION')) + ")"); }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/base"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $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/error"); return self.$require("corelib/constants"); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/nil"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2, $truthy = Opal.truthy; Opal.add_stubs(['$raise', '$name', '$new', '$>', '$length', '$Rational']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NilClass'); var $nesting = [self].concat($parent_nesting), $NilClass_$excl$2, $NilClass_$$3, $NilClass_$$4, $NilClass_$$5, $NilClass_$eq_eq$6, $NilClass_dup$7, $NilClass_clone$8, $NilClass_inspect$9, $NilClass_nil$ques$10, $NilClass_singleton_class$11, $NilClass_to_a$12, $NilClass_to_h$13, $NilClass_to_i$14, $NilClass_to_s$15, $NilClass_to_c$16, $NilClass_rationalize$17, $NilClass_to_r$18, $NilClass_instance_variables$19; self.$$prototype.$$meta = self; (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $allocate$1; Opal.def(self, '$allocate', $allocate$1 = function $$allocate() { var self = this; return self.$raise($$($nesting, 'TypeError'), "" + "allocator undefined for " + (self.$name())) }, $allocate$1.$$arity = 0); Opal.udef(self, '$' + "new");; return nil;; })(Opal.get_singleton_class(self), $nesting); Opal.def(self, '$!', $NilClass_$excl$2 = function() { var self = this; return true }, $NilClass_$excl$2.$$arity = 0); Opal.def(self, '$&', $NilClass_$$3 = function(other) { var self = this; return false }, $NilClass_$$3.$$arity = 1); Opal.def(self, '$|', $NilClass_$$4 = function(other) { var self = this; return other !== false && other !== nil; }, $NilClass_$$4.$$arity = 1); Opal.def(self, '$^', $NilClass_$$5 = function(other) { var self = this; return other !== false && other !== nil; }, $NilClass_$$5.$$arity = 1); Opal.def(self, '$==', $NilClass_$eq_eq$6 = function(other) { var self = this; return other === nil; }, $NilClass_$eq_eq$6.$$arity = 1); Opal.def(self, '$dup', $NilClass_dup$7 = function $$dup() { var self = this; return nil }, $NilClass_dup$7.$$arity = 0); Opal.def(self, '$clone', $NilClass_clone$8 = function $$clone($kwargs) { var freeze, self = this; if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; freeze = $kwargs.$$smap["freeze"]; if (freeze == null) { freeze = true }; return nil; }, $NilClass_clone$8.$$arity = -1); Opal.def(self, '$inspect', $NilClass_inspect$9 = function $$inspect() { var self = this; return "nil" }, $NilClass_inspect$9.$$arity = 0); Opal.def(self, '$nil?', $NilClass_nil$ques$10 = function() { var self = this; return true }, $NilClass_nil$ques$10.$$arity = 0); Opal.def(self, '$singleton_class', $NilClass_singleton_class$11 = function $$singleton_class() { var self = this; return $$($nesting, 'NilClass') }, $NilClass_singleton_class$11.$$arity = 0); Opal.def(self, '$to_a', $NilClass_to_a$12 = function $$to_a() { var self = this; return [] }, $NilClass_to_a$12.$$arity = 0); Opal.def(self, '$to_h', $NilClass_to_h$13 = function $$to_h() { var self = this; return Opal.hash(); }, $NilClass_to_h$13.$$arity = 0); Opal.def(self, '$to_i', $NilClass_to_i$14 = function $$to_i() { var self = this; return 0 }, $NilClass_to_i$14.$$arity = 0); Opal.alias(self, "to_f", "to_i"); Opal.def(self, '$to_s', $NilClass_to_s$15 = function $$to_s() { var self = this; return "" }, $NilClass_to_s$15.$$arity = 0); Opal.def(self, '$to_c', $NilClass_to_c$16 = function $$to_c() { var self = this; return $$($nesting, 'Complex').$new(0, 0) }, $NilClass_to_c$16.$$arity = 0); Opal.def(self, '$rationalize', $NilClass_rationalize$17 = function $$rationalize($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($rb_gt(args.$length(), 1))) { self.$raise($$($nesting, 'ArgumentError'))}; return self.$Rational(0, 1); }, $NilClass_rationalize$17.$$arity = -1); Opal.def(self, '$to_r', $NilClass_to_r$18 = function $$to_r() { var self = this; return self.$Rational(0, 1) }, $NilClass_to_r$18.$$arity = 0); return (Opal.def(self, '$instance_variables', $NilClass_instance_variables$19 = function $$instance_variables() { var self = this; return [] }, $NilClass_instance_variables$19.$$arity = 0), nil) && 'instance_variables'; })($nesting[0], null, $nesting); return Opal.const_set($nesting[0], 'NIL', nil); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/boolean"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2; Opal.add_stubs(['$raise', '$name']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Boolean'); var $nesting = [self].concat($parent_nesting), $Boolean___id__$2, $Boolean_$excl$3, $Boolean_$$4, $Boolean_$$5, $Boolean_$$6, $Boolean_$eq_eq$7, $Boolean_singleton_class$8, $Boolean_to_s$9, $Boolean_dup$10, $Boolean_clone$11; Opal.defineProperty(self.$$prototype, '$$is_boolean', true); Opal.defineProperty(self.$$prototype, '$$meta', self); (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $allocate$1; Opal.def(self, '$allocate', $allocate$1 = function $$allocate() { var self = this; return self.$raise($$($nesting, 'TypeError'), "" + "allocator undefined for " + (self.$name())) }, $allocate$1.$$arity = 0); Opal.udef(self, '$' + "new");; return nil;; })(Opal.get_singleton_class(self), $nesting); Opal.def(self, '$__id__', $Boolean___id__$2 = function $$__id__() { var self = this; return self.valueOf() ? 2 : 0; }, $Boolean___id__$2.$$arity = 0); Opal.alias(self, "object_id", "__id__"); Opal.def(self, '$!', $Boolean_$excl$3 = function() { var self = this; return self != true; }, $Boolean_$excl$3.$$arity = 0); Opal.def(self, '$&', $Boolean_$$4 = function(other) { var self = this; return (self == true) ? (other !== false && other !== nil) : false; }, $Boolean_$$4.$$arity = 1); Opal.def(self, '$|', $Boolean_$$5 = function(other) { var self = this; return (self == true) ? true : (other !== false && other !== nil); }, $Boolean_$$5.$$arity = 1); Opal.def(self, '$^', $Boolean_$$6 = function(other) { var self = this; return (self == true) ? (other === false || other === nil) : (other !== false && other !== nil); }, $Boolean_$$6.$$arity = 1); Opal.def(self, '$==', $Boolean_$eq_eq$7 = function(other) { var self = this; return (self == true) === other.valueOf(); }, $Boolean_$eq_eq$7.$$arity = 1); Opal.alias(self, "equal?", "=="); Opal.alias(self, "eql?", "=="); Opal.def(self, '$singleton_class', $Boolean_singleton_class$8 = function $$singleton_class() { var self = this; return $$($nesting, 'Boolean') }, $Boolean_singleton_class$8.$$arity = 0); Opal.def(self, '$to_s', $Boolean_to_s$9 = function $$to_s() { var self = this; return (self == true) ? 'true' : 'false'; }, $Boolean_to_s$9.$$arity = 0); Opal.def(self, '$dup', $Boolean_dup$10 = function $$dup() { var self = this; return self }, $Boolean_dup$10.$$arity = 0); return (Opal.def(self, '$clone', $Boolean_clone$11 = function $$clone($kwargs) { var freeze, self = this; if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; freeze = $kwargs.$$smap["freeze"]; if (freeze == null) { freeze = true }; return self; }, $Boolean_clone$11.$$arity = -1), nil) && 'clone'; })($nesting[0], Boolean, $nesting); Opal.const_set($nesting[0], 'TrueClass', $$($nesting, 'Boolean')); Opal.const_set($nesting[0], 'FalseClass', $$($nesting, 'Boolean')); Opal.const_set($nesting[0], 'TRUE', true); return Opal.const_set($nesting[0], 'FALSE', false); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/comparable"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy; Opal.add_stubs(['$>', '$<', '$===', '$raise', '$class', '$equal?', '$<=>']); return (function($base, $parent_nesting) { var self = $module($base, 'Comparable'); var $nesting = [self].concat($parent_nesting), $Comparable_$eq_eq$1, $Comparable_$gt$2, $Comparable_$gt_eq$3, $Comparable_$lt$4, $Comparable_$lt_eq$5, $Comparable_between$ques$6, $Comparable_clamp$7, $case = nil; function normalize(what) { if (Opal.is_a(what, Opal.Integer)) { return what; } if ($rb_gt(what, 0)) { return 1; } if ($rb_lt(what, 0)) { return -1; } return 0; } function fail_comparison(lhs, rhs) { var class_name; (function() {$case = rhs; if (nil['$===']($case) || true['$===']($case) || false['$===']($case) || $$($nesting, 'Integer')['$===']($case) || $$($nesting, 'Float')['$===']($case)) {return class_name = rhs.$inspect();} else {return class_name = rhs.$$class;}})() self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + ((lhs).$class()) + " with " + (class_name) + " failed") } ; Opal.def(self, '$==', $Comparable_$eq_eq$1 = function(other) { var self = this, cmp = nil; if ($truthy(self['$equal?'](other))) { return true}; if (self["$<=>"] == Opal.Kernel["$<=>"]) { return false; } // check for infinite recursion if (self.$$comparable) { delete self.$$comparable; return false; } ; if ($truthy((cmp = self['$<=>'](other)))) { } else { return false }; return normalize(cmp) == 0;; }, $Comparable_$eq_eq$1.$$arity = 1); Opal.def(self, '$>', $Comparable_$gt$2 = function(other) { var self = this, cmp = nil; if ($truthy((cmp = self['$<=>'](other)))) { } else { fail_comparison(self, other) }; return normalize(cmp) > 0;; }, $Comparable_$gt$2.$$arity = 1); Opal.def(self, '$>=', $Comparable_$gt_eq$3 = function(other) { var self = this, cmp = nil; if ($truthy((cmp = self['$<=>'](other)))) { } else { fail_comparison(self, other) }; return normalize(cmp) >= 0;; }, $Comparable_$gt_eq$3.$$arity = 1); Opal.def(self, '$<', $Comparable_$lt$4 = function(other) { var self = this, cmp = nil; if ($truthy((cmp = self['$<=>'](other)))) { } else { fail_comparison(self, other) }; return normalize(cmp) < 0;; }, $Comparable_$lt$4.$$arity = 1); Opal.def(self, '$<=', $Comparable_$lt_eq$5 = function(other) { var self = this, cmp = nil; if ($truthy((cmp = self['$<=>'](other)))) { } else { fail_comparison(self, other) }; return normalize(cmp) <= 0;; }, $Comparable_$lt_eq$5.$$arity = 1); Opal.def(self, '$between?', $Comparable_between$ques$6 = function(min, max) { var self = this; if ($rb_lt(self, min)) { return false}; if ($rb_gt(self, max)) { return false}; return true; }, $Comparable_between$ques$6.$$arity = 2); Opal.def(self, '$clamp', $Comparable_clamp$7 = function $$clamp(min, max) { var self = this, cmp = nil; cmp = min['$<=>'](max); if ($truthy(cmp)) { } else { fail_comparison(min, max) }; if ($truthy(normalize(cmp) > 0)) { self.$raise($$($nesting, 'ArgumentError'), "min argument must be smaller than max argument")}; if ($truthy(normalize(self['$<=>'](min)) < 0)) { return min}; if ($truthy(normalize(self['$<=>'](max)) > 0)) { return max}; return self; }, $Comparable_clamp$7.$$arity = 2); })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/regexp"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $gvars = Opal.gvars; Opal.add_stubs(['$nil?', '$[]', '$raise', '$escape', '$options', '$to_str', '$new', '$join', '$coerce_to!', '$!', '$match', '$coerce_to?', '$begin', '$coerce_to', '$=~', '$attr_reader', '$===', '$inspect', '$to_a']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'RegexpError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Regexp'); var $nesting = [self].concat($parent_nesting), $Regexp_$eq_eq$6, $Regexp_$eq_eq_eq$7, $Regexp_$eq_tilde$8, $Regexp_inspect$9, $Regexp_match$10, $Regexp_match$ques$11, $Regexp_$$12, $Regexp_source$13, $Regexp_options$14, $Regexp_casefold$ques$15; Opal.const_set($nesting[0], 'IGNORECASE', 1); Opal.const_set($nesting[0], 'EXTENDED', 2); Opal.const_set($nesting[0], 'MULTILINE', 4); Opal.defineProperty(self.$$prototype, '$$is_regexp', true); (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $allocate$1, $escape$2, $last_match$3, $union$4, $new$5; Opal.def(self, '$allocate', $allocate$1 = function $$allocate() { var $iter = $allocate$1.$$p, $yield = $iter || nil, self = this, allocated = nil, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $allocate$1.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } allocated = $send(self, Opal.find_super_dispatcher(self, 'allocate', $allocate$1, false), $zuper, $iter); allocated.uninitialized = true; return allocated; }, $allocate$1.$$arity = 0); Opal.def(self, '$escape', $escape$2 = function $$escape(string) { var self = this; return Opal.escape_regexp(string); }, $escape$2.$$arity = 1); Opal.def(self, '$last_match', $last_match$3 = function $$last_match(n) { var self = this; if ($gvars["~"] == null) $gvars["~"] = nil; if (n == null) { n = nil; }; if ($truthy(n['$nil?']())) { return $gvars["~"] } else { return $gvars["~"]['$[]'](n) }; }, $last_match$3.$$arity = -1); Opal.alias(self, "quote", "escape"); Opal.def(self, '$union', $union$4 = function $$union($a) { var $post_args, parts, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); parts = $post_args;; var is_first_part_array, quoted_validated, part, options, each_part_options; if (parts.length == 0) { return /(?!)/; } // return fast if there's only one element if (parts.length == 1 && parts[0].$$is_regexp) { return parts[0]; } // cover the 2 arrays passed as arguments case is_first_part_array = parts[0].$$is_array; if (parts.length > 1 && is_first_part_array) { self.$raise($$($nesting, 'TypeError'), "no implicit conversion of Array into String") } // deal with splat issues (related to https://github.com/opal/opal/issues/858) if (is_first_part_array) { parts = parts[0]; } options = undefined; quoted_validated = []; for (var i=0; i < parts.length; i++) { part = parts[i]; if (part.$$is_string) { quoted_validated.push(self.$escape(part)); } else if (part.$$is_regexp) { each_part_options = (part).$options(); if (options != undefined && options != each_part_options) { self.$raise($$($nesting, 'TypeError'), "All expressions must use the same options") } options = each_part_options; quoted_validated.push('('+part.source+')'); } else { quoted_validated.push(self.$escape((part).$to_str())); } } ; return self.$new((quoted_validated).$join("|"), options); }, $union$4.$$arity = -1); return (Opal.def(self, '$new', $new$5 = function(regexp, options) { var self = this; ; if (regexp.$$is_regexp) { return new RegExp(regexp); } regexp = $$($nesting, 'Opal')['$coerce_to!'](regexp, $$($nesting, 'String'), "to_str"); if (regexp.charAt(regexp.length - 1) === '\\' && regexp.charAt(regexp.length - 2) !== '\\') { self.$raise($$($nesting, 'RegexpError'), "" + "too short escape sequence: /" + (regexp) + "/") } if (options === undefined || options['$!']()) { return new RegExp(regexp); } if (options.$$is_number) { var temp = ''; if ($$($nesting, 'IGNORECASE') & options) { temp += 'i'; } if ($$($nesting, 'MULTILINE') & options) { temp += 'm'; } options = temp; } else { options = 'i'; } return new RegExp(regexp, options); ; }, $new$5.$$arity = -2), nil) && 'new'; })(Opal.get_singleton_class(self), $nesting); Opal.def(self, '$==', $Regexp_$eq_eq$6 = function(other) { var self = this; return other instanceof RegExp && self.toString() === other.toString(); }, $Regexp_$eq_eq$6.$$arity = 1); Opal.def(self, '$===', $Regexp_$eq_eq_eq$7 = function(string) { var self = this; return self.$match($$($nesting, 'Opal')['$coerce_to?'](string, $$($nesting, 'String'), "to_str")) !== nil }, $Regexp_$eq_eq_eq$7.$$arity = 1); Opal.def(self, '$=~', $Regexp_$eq_tilde$8 = function(string) { var $a, self = this; if ($gvars["~"] == null) $gvars["~"] = nil; return ($truthy($a = self.$match(string)) ? $gvars["~"].$begin(0) : $a) }, $Regexp_$eq_tilde$8.$$arity = 1); Opal.alias(self, "eql?", "=="); Opal.def(self, '$inspect', $Regexp_inspect$9 = function $$inspect() { var self = this; var regexp_format = /^\/(.*)\/([^\/]*)$/; var value = self.toString(); var matches = regexp_format.exec(value); if (matches) { var regexp_pattern = matches[1]; var regexp_flags = matches[2]; var chars = regexp_pattern.split(''); var chars_length = chars.length; var char_escaped = false; var regexp_pattern_escaped = ''; for (var i = 0; i < chars_length; i++) { var current_char = chars[i]; if (!char_escaped && current_char == '/') { regexp_pattern_escaped = regexp_pattern_escaped.concat('\\'); } regexp_pattern_escaped = regexp_pattern_escaped.concat(current_char); if (current_char == '\\') { if (char_escaped) { // does not over escape char_escaped = false; } else { char_escaped = true; } } else { char_escaped = false; } } return '/' + regexp_pattern_escaped + '/' + regexp_flags; } else { return value; } }, $Regexp_inspect$9.$$arity = 0); Opal.def(self, '$match', $Regexp_match$10 = function $$match(string, pos) { var $iter = $Regexp_match$10.$$p, block = $iter || nil, self = this; if ($gvars["~"] == null) $gvars["~"] = nil; if ($iter) $Regexp_match$10.$$p = null; if ($iter) $Regexp_match$10.$$p = null;; ; if (self.uninitialized) { self.$raise($$($nesting, 'TypeError'), "uninitialized Regexp") } if (pos === undefined) { if (string === nil) return ($gvars["~"] = nil); var m = self.exec($$($nesting, 'Opal').$coerce_to(string, $$($nesting, 'String'), "to_str")); if (m) { ($gvars["~"] = $$($nesting, 'MatchData').$new(self, m)); return block === nil ? $gvars["~"] : Opal.yield1(block, $gvars["~"]); } else { return ($gvars["~"] = nil); } } pos = $$($nesting, 'Opal').$coerce_to(pos, $$($nesting, 'Integer'), "to_int"); if (string === nil) { return ($gvars["~"] = nil); } string = $$($nesting, 'Opal').$coerce_to(string, $$($nesting, 'String'), "to_str"); if (pos < 0) { pos += string.length; if (pos < 0) { return ($gvars["~"] = nil); } } // global RegExp maintains state, so not using self/this var md, re = Opal.global_regexp(self); while (true) { md = re.exec(string); if (md === null) { return ($gvars["~"] = nil); } if (md.index >= pos) { ($gvars["~"] = $$($nesting, 'MatchData').$new(re, md)); return block === nil ? $gvars["~"] : Opal.yield1(block, $gvars["~"]); } re.lastIndex = md.index + 1; } ; }, $Regexp_match$10.$$arity = -2); Opal.def(self, '$match?', $Regexp_match$ques$11 = function(string, pos) { var self = this; ; if (self.uninitialized) { self.$raise($$($nesting, 'TypeError'), "uninitialized Regexp") } if (pos === undefined) { return string === nil ? false : self.test($$($nesting, 'Opal').$coerce_to(string, $$($nesting, 'String'), "to_str")); } pos = $$($nesting, 'Opal').$coerce_to(pos, $$($nesting, 'Integer'), "to_int"); if (string === nil) { return false; } string = $$($nesting, 'Opal').$coerce_to(string, $$($nesting, 'String'), "to_str"); if (pos < 0) { pos += string.length; if (pos < 0) { return false; } } // global RegExp maintains state, so not using self/this var md, re = Opal.global_regexp(self); md = re.exec(string); if (md === null || md.index < pos) { return false; } else { return true; } ; }, $Regexp_match$ques$11.$$arity = -2); Opal.def(self, '$~', $Regexp_$$12 = function() { var self = this; if ($gvars._ == null) $gvars._ = nil; return self['$=~']($gvars._) }, $Regexp_$$12.$$arity = 0); Opal.def(self, '$source', $Regexp_source$13 = function $$source() { var self = this; return self.source; }, $Regexp_source$13.$$arity = 0); Opal.def(self, '$options', $Regexp_options$14 = function $$options() { var self = this; if (self.uninitialized) { self.$raise($$($nesting, 'TypeError'), "uninitialized Regexp") } var result = 0; // should be supported in IE6 according to https://msdn.microsoft.com/en-us/library/7f5z26w4(v=vs.94).aspx if (self.multiline) { result |= $$($nesting, 'MULTILINE'); } if (self.ignoreCase) { result |= $$($nesting, 'IGNORECASE'); } return result; }, $Regexp_options$14.$$arity = 0); Opal.def(self, '$casefold?', $Regexp_casefold$ques$15 = function() { var self = this; return self.ignoreCase; }, $Regexp_casefold$ques$15.$$arity = 0); return Opal.alias(self, "to_s", "source"); })($nesting[0], RegExp, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'MatchData'); var $nesting = [self].concat($parent_nesting), $MatchData_initialize$16, $MatchData_$$$17, $MatchData_offset$18, $MatchData_$eq_eq$19, $MatchData_begin$20, $MatchData_end$21, $MatchData_captures$22, $MatchData_inspect$23, $MatchData_length$24, $MatchData_to_a$25, $MatchData_to_s$26, $MatchData_values_at$27; self.$$prototype.matches = nil; self.$attr_reader("post_match", "pre_match", "regexp", "string"); Opal.def(self, '$initialize', $MatchData_initialize$16 = function $$initialize(regexp, match_groups) { var self = this; $gvars["~"] = self; self.regexp = regexp; self.begin = match_groups.index; self.string = match_groups.input; self.pre_match = match_groups.input.slice(0, match_groups.index); self.post_match = match_groups.input.slice(match_groups.index + match_groups[0].length); 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); } } ; }, $MatchData_initialize$16.$$arity = 2); Opal.def(self, '$[]', $MatchData_$$$17 = function($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.matches, '[]', Opal.to_a(args)); }, $MatchData_$$$17.$$arity = -1); Opal.def(self, '$offset', $MatchData_offset$18 = function $$offset(n) { var self = this; if (n !== 0) { self.$raise($$($nesting, 'ArgumentError'), "MatchData#offset only supports 0th element") } return [self.begin, self.begin + self.matches[n].length]; }, $MatchData_offset$18.$$arity = 1); Opal.def(self, '$==', $MatchData_$eq_eq$19 = function(other) { var $a, $b, $c, $d, self = this; if ($truthy($$($nesting, 'MatchData')['$==='](other))) { } else { return false }; return ($truthy($a = ($truthy($b = ($truthy($c = ($truthy($d = self.string == other.string) ? self.regexp.toString() == other.regexp.toString() : $d)) ? self.pre_match == other.pre_match : $c)) ? self.post_match == other.post_match : $b)) ? self.begin == other.begin : $a); }, $MatchData_$eq_eq$19.$$arity = 1); Opal.alias(self, "eql?", "=="); Opal.def(self, '$begin', $MatchData_begin$20 = function $$begin(n) { var self = this; if (n !== 0) { self.$raise($$($nesting, 'ArgumentError'), "MatchData#begin only supports 0th element") } return self.begin; }, $MatchData_begin$20.$$arity = 1); Opal.def(self, '$end', $MatchData_end$21 = function $$end(n) { var self = this; if (n !== 0) { self.$raise($$($nesting, 'ArgumentError'), "MatchData#end only supports 0th element") } return self.begin + self.matches[n].length; }, $MatchData_end$21.$$arity = 1); Opal.def(self, '$captures', $MatchData_captures$22 = function $$captures() { var self = this; return self.matches.slice(1) }, $MatchData_captures$22.$$arity = 0); Opal.def(self, '$inspect', $MatchData_inspect$23 = function $$inspect() { var self = this; var str = "#"; }, $MatchData_inspect$23.$$arity = 0); Opal.def(self, '$length', $MatchData_length$24 = function $$length() { var self = this; return self.matches.length }, $MatchData_length$24.$$arity = 0); Opal.alias(self, "size", "length"); Opal.def(self, '$to_a', $MatchData_to_a$25 = function $$to_a() { var self = this; return self.matches }, $MatchData_to_a$25.$$arity = 0); Opal.def(self, '$to_s', $MatchData_to_s$26 = function $$to_s() { var self = this; return self.matches[0] }, $MatchData_to_s$26.$$arity = 0); return (Opal.def(self, '$values_at', $MatchData_values_at$27 = function $$values_at($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var i, a, index, values = []; for (i = 0; i < args.length; i++) { if (args[i].$$is_range) { a = (args[i]).$to_a(); a.unshift(i, 1); Array.prototype.splice.apply(args, a); } index = $$($nesting, 'Opal')['$coerce_to!'](args[i], $$($nesting, 'Integer'), "to_int"); if (index < 0) { index += self.matches.length; if (index < 0) { values.push(nil); continue; } } values.push(self.matches[index]); } return values; ; }, $MatchData_values_at$27.$$arity = -1), nil) && 'values_at'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/string"] = function(Opal) { function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $gvars = Opal.gvars; Opal.add_stubs(['$require', '$include', '$coerce_to?', '$coerce_to', '$raise', '$===', '$format', '$to_s', '$respond_to?', '$to_str', '$<=>', '$==', '$=~', '$new', '$force_encoding', '$casecmp', '$empty?', '$ljust', '$ceil', '$/', '$+', '$rjust', '$floor', '$to_a', '$each_char', '$to_proc', '$coerce_to!', '$copy_singleton_methods', '$initialize_clone', '$initialize_dup', '$enum_for', '$size', '$chomp', '$[]', '$to_i', '$each_line', '$encoding', '$class', '$match', '$match?', '$captures', '$proc', '$succ', '$escape']); self.$require("corelib/comparable"); self.$require("corelib/regexp"); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String___id__$1, $String_try_convert$2, $String_new$3, $String_initialize$4, $String_$percent$5, $String_$$6, $String_$plus$7, $String_$lt_eq_gt$8, $String_$eq_eq$9, $String_$eq_tilde$10, $String_$$$11, $String_b$12, $String_capitalize$13, $String_casecmp$14, $String_casecmp$ques$15, $String_center$16, $String_chars$17, $String_chomp$18, $String_chop$19, $String_chr$20, $String_clone$21, $String_dup$22, $String_count$23, $String_delete$24, $String_delete_prefix$25, $String_delete_suffix$26, $String_downcase$27, $String_each_char$28, $String_each_line$30, $String_empty$ques$31, $String_end_with$ques$32, $String_gsub$33, $String_hash$34, $String_hex$35, $String_include$ques$36, $String_index$37, $String_inspect$38, $String_intern$39, $String_lines$40, $String_length$41, $String_ljust$42, $String_lstrip$43, $String_ascii_only$ques$44, $String_match$45, $String_match$ques$46, $String_next$47, $String_oct$48, $String_ord$49, $String_partition$50, $String_reverse$51, $String_rindex$52, $String_rjust$53, $String_rpartition$54, $String_rstrip$55, $String_scan$56, $String_split$57, $String_squeeze$58, $String_start_with$ques$59, $String_strip$60, $String_sub$61, $String_sum$62, $String_swapcase$63, $String_to_f$64, $String_to_i$65, $String_to_proc$66, $String_to_s$68, $String_tr$69, $String_tr_s$70, $String_upcase$71, $String_upto$72, $String_instance_variables$73, $String__load$74, $String_unicode_normalize$75, $String_unicode_normalized$ques$76, $String_unpack$77, $String_unpack1$78; self.$include($$($nesting, 'Comparable')); Opal.defineProperty(self.$$prototype, '$$is_string', true); Opal.defineProperty(self.$$prototype, '$$cast', function(string) { var klass = this.$$class; if (klass.$$constructor === String) { return string; } else { return new klass.$$constructor(string); } }); ; Opal.def(self, '$__id__', $String___id__$1 = function $$__id__() { var self = this; return self.toString(); }, $String___id__$1.$$arity = 0); Opal.alias(self, "object_id", "__id__"); Opal.defs(self, '$try_convert', $String_try_convert$2 = function $$try_convert(what) { var self = this; return $$($nesting, 'Opal')['$coerce_to?'](what, $$($nesting, 'String'), "to_str") }, $String_try_convert$2.$$arity = 1); Opal.defs(self, '$new', $String_new$3 = function(str) { var self = this; if (str == null) { str = ""; }; str = $$($nesting, 'Opal').$coerce_to(str, $$($nesting, 'String'), "to_str"); return new self.$$constructor(str);; }, $String_new$3.$$arity = -1); Opal.def(self, '$initialize', $String_initialize$4 = function $$initialize(str) { var self = this; ; if (str === undefined) { return self; } ; return self.$raise($$($nesting, 'NotImplementedError'), "Mutable strings are not supported in Opal."); }, $String_initialize$4.$$arity = -1); Opal.def(self, '$%', $String_$percent$5 = function(data) { var self = this; if ($truthy($$($nesting, 'Array')['$==='](data))) { return $send(self, 'format', [self].concat(Opal.to_a(data))) } else { return self.$format(self, data) } }, $String_$percent$5.$$arity = 1); Opal.def(self, '$*', $String_$$6 = function(count) { var self = this; count = $$($nesting, 'Opal').$coerce_to(count, $$($nesting, 'Integer'), "to_int"); if (count < 0) { self.$raise($$($nesting, 'ArgumentError'), "negative argument") } if (count === 0) { return self.$$cast(''); } var result = '', string = self.toString(); // All credit for the bit-twiddling magic code below goes to Mozilla // polyfill implementation of String.prototype.repeat() posted here: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat if (string.length * count >= 1 << 28) { self.$raise($$($nesting, 'RangeError'), "multiply count must not overflow maximum string size") } for (;;) { if ((count & 1) === 1) { result += string; } count >>>= 1; if (count === 0) { break; } string += string; } return self.$$cast(result); }, $String_$$6.$$arity = 1); Opal.def(self, '$+', $String_$plus$7 = function(other) { var self = this; other = $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'String'), "to_str"); return self + other.$to_s(); }, $String_$plus$7.$$arity = 1); Opal.def(self, '$<=>', $String_$lt_eq_gt$8 = function(other) { var self = this; if ($truthy(other['$respond_to?']("to_str"))) { 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); } } }, $String_$lt_eq_gt$8.$$arity = 1); Opal.def(self, '$==', $String_$eq_eq$9 = function(other) { var self = this; if (other.$$is_string) { return self.toString() === other.toString(); } if ($$($nesting, 'Opal')['$respond_to?'](other, "to_str")) { return other['$=='](self); } return false; }, $String_$eq_eq$9.$$arity = 1); Opal.alias(self, "eql?", "=="); Opal.alias(self, "===", "=="); Opal.def(self, '$=~', $String_$eq_tilde$10 = function(other) { var self = this; if (other.$$is_string) { self.$raise($$($nesting, 'TypeError'), "type mismatch: String given"); } return other['$=~'](self); }, $String_$eq_tilde$10.$$arity = 1); Opal.def(self, '$[]', $String_$$$11 = function(index, length) { var self = this; ; var size = self.length, exclude; if (index.$$is_range) { exclude = index.excl; length = $$($nesting, 'Opal').$coerce_to(index.end, $$($nesting, 'Integer'), "to_int"); index = $$($nesting, 'Opal').$coerce_to(index.begin, $$($nesting, 'Integer'), "to_int"); if (Math.abs(index) > size) { return nil; } if (index < 0) { index += size; } if (length < 0) { length += size; } if (!exclude) { length += 1; } length = length - index; if (length < 0) { length = 0; } return self.$$cast(self.substr(index, length)); } if (index.$$is_string) { if (length != null) { self.$raise($$($nesting, 'TypeError')) } return self.indexOf(index) !== -1 ? self.$$cast(index) : nil; } if (index.$$is_regexp) { var match = self.match(index); if (match === null) { ($gvars["~"] = nil) return nil; } ($gvars["~"] = $$($nesting, 'MatchData').$new(index, match)) if (length == null) { return self.$$cast(match[0]); } length = $$($nesting, 'Opal').$coerce_to(length, $$($nesting, 'Integer'), "to_int"); if (length < 0 && -length < match.length) { return self.$$cast(match[length += match.length]); } if (length >= 0 && length < match.length) { return self.$$cast(match[length]); } return nil; } index = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, 'Integer'), "to_int"); if (index < 0) { index += size; } if (length == null) { if (index >= size || index < 0) { return nil; } return self.$$cast(self.substr(index, 1)); } length = $$($nesting, 'Opal').$coerce_to(length, $$($nesting, 'Integer'), "to_int"); if (length < 0) { return nil; } if (index > size || index < 0) { return nil; } return self.$$cast(self.substr(index, length)); ; }, $String_$$$11.$$arity = -2); Opal.alias(self, "byteslice", "[]"); Opal.def(self, '$b', $String_b$12 = function $$b() { var self = this; return self.$force_encoding("binary") }, $String_b$12.$$arity = 0); Opal.def(self, '$capitalize', $String_capitalize$13 = function $$capitalize() { var self = this; return self.$$cast(self.charAt(0).toUpperCase() + self.substr(1).toLowerCase()); }, $String_capitalize$13.$$arity = 0); Opal.def(self, '$casecmp', $String_casecmp$14 = function $$casecmp(other) { var self = this; if ($truthy(other['$respond_to?']("to_str"))) { } else { return nil }; other = $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'String'), "to_str").$to_s(); var ascii_only = /^[\x00-\x7F]*$/; if (ascii_only.test(self) && ascii_only.test(other)) { self = self.toLowerCase(); other = other.toLowerCase(); } ; return self['$<=>'](other); }, $String_casecmp$14.$$arity = 1); Opal.def(self, '$casecmp?', $String_casecmp$ques$15 = function(other) { var self = this; var cmp = self.$casecmp(other); if (cmp === nil) { return nil; } else { return cmp === 0; } }, $String_casecmp$ques$15.$$arity = 1); Opal.def(self, '$center', $String_center$16 = function $$center(width, padstr) { var self = this; if (padstr == null) { padstr = " "; }; width = $$($nesting, 'Opal').$coerce_to(width, $$($nesting, 'Integer'), "to_int"); padstr = $$($nesting, 'Opal').$coerce_to(padstr, $$($nesting, 'String'), "to_str").$to_s(); if ($truthy(padstr['$empty?']())) { self.$raise($$($nesting, 'ArgumentError'), "zero width padding")}; if ($truthy(width <= self.length)) { return self}; var ljustified = self.$ljust($rb_divide($rb_plus(width, self.length), 2).$ceil(), padstr), rjustified = self.$rjust($rb_divide($rb_plus(width, self.length), 2).$floor(), padstr); return self.$$cast(rjustified + ljustified.slice(self.length)); ; }, $String_center$16.$$arity = -2); Opal.def(self, '$chars', $String_chars$17 = function $$chars() { var $iter = $String_chars$17.$$p, block = $iter || nil, self = this; if ($iter) $String_chars$17.$$p = null; if ($iter) $String_chars$17.$$p = null;; if ($truthy(block)) { } else { return self.$each_char().$to_a() }; return $send(self, 'each_char', [], block.$to_proc()); }, $String_chars$17.$$arity = 0); Opal.def(self, '$chomp', $String_chomp$18 = function $$chomp(separator) { var self = this; if ($gvars["/"] == null) $gvars["/"] = nil; if (separator == null) { separator = $gvars["/"]; }; if ($truthy(separator === nil || self.length === 0)) { return self}; separator = $$($nesting, 'Opal')['$coerce_to!'](separator, $$($nesting, 'String'), "to_str").$to_s(); var result; if (separator === "\n") { result = self.replace(/\r?\n?$/, ''); } else if (separator === "") { result = self.replace(/(\r?\n)+$/, ''); } else if (self.length >= separator.length) { var tail = self.substr(self.length - separator.length, separator.length); if (tail === separator) { result = self.substr(0, self.length - separator.length); } } if (result != null) { return self.$$cast(result); } ; return self; }, $String_chomp$18.$$arity = -1); Opal.def(self, '$chop', $String_chop$19 = function $$chop() { var self = this; var length = self.length, result; if (length <= 1) { result = ""; } else if (self.charAt(length - 1) === "\n" && self.charAt(length - 2) === "\r") { result = self.substr(0, length - 2); } else { result = self.substr(0, length - 1); } return self.$$cast(result); }, $String_chop$19.$$arity = 0); Opal.def(self, '$chr', $String_chr$20 = function $$chr() { var self = this; return self.charAt(0); }, $String_chr$20.$$arity = 0); Opal.def(self, '$clone', $String_clone$21 = function $$clone() { var self = this, copy = nil; copy = self.slice(); copy.$copy_singleton_methods(self); copy.$initialize_clone(self); return copy; }, $String_clone$21.$$arity = 0); Opal.def(self, '$dup', $String_dup$22 = function $$dup() { var self = this, copy = nil; copy = self.slice(); copy.$initialize_dup(self); return copy; }, $String_dup$22.$$arity = 0); Opal.def(self, '$count', $String_count$23 = function $$count($a) { var $post_args, sets, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); sets = $post_args;; if (sets.length === 0) { self.$raise($$($nesting, 'ArgumentError'), "ArgumentError: wrong number of arguments (0 for 1+)") } var char_class = char_class_from_char_sets(sets); if (char_class === null) { return 0; } return self.length - self.replace(new RegExp(char_class, 'g'), '').length; ; }, $String_count$23.$$arity = -1); Opal.def(self, '$delete', $String_delete$24 = function($a) { var $post_args, sets, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); sets = $post_args;; if (sets.length === 0) { self.$raise($$($nesting, 'ArgumentError'), "ArgumentError: wrong number of arguments (0 for 1+)") } var char_class = char_class_from_char_sets(sets); if (char_class === null) { return self; } return self.$$cast(self.replace(new RegExp(char_class, 'g'), '')); ; }, $String_delete$24.$$arity = -1); Opal.def(self, '$delete_prefix', $String_delete_prefix$25 = function $$delete_prefix(prefix) { var self = this; if (!prefix.$$is_string) { (prefix = $$($nesting, 'Opal').$coerce_to(prefix, $$($nesting, 'String'), "to_str")) } if (self.slice(0, prefix.length) === prefix) { return self.$$cast(self.slice(prefix.length)); } else { return self; } }, $String_delete_prefix$25.$$arity = 1); Opal.def(self, '$delete_suffix', $String_delete_suffix$26 = function $$delete_suffix(suffix) { var self = this; if (!suffix.$$is_string) { (suffix = $$($nesting, 'Opal').$coerce_to(suffix, $$($nesting, 'String'), "to_str")) } if (self.slice(self.length - suffix.length) === suffix) { return self.$$cast(self.slice(0, self.length - suffix.length)); } else { return self; } }, $String_delete_suffix$26.$$arity = 1); Opal.def(self, '$downcase', $String_downcase$27 = function $$downcase() { var self = this; return self.$$cast(self.toLowerCase()); }, $String_downcase$27.$$arity = 0); Opal.def(self, '$each_char', $String_each_char$28 = function $$each_char() { var $iter = $String_each_char$28.$$p, block = $iter || nil, $$29, self = this; if ($iter) $String_each_char$28.$$p = null; if ($iter) $String_each_char$28.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["each_char"], ($$29 = function(){var self = $$29.$$s || this; return self.$size()}, $$29.$$s = self, $$29.$$arity = 0, $$29)) }; for (var i = 0, length = self.length; i < length; i++) { Opal.yield1(block, self.charAt(i)); } ; return self; }, $String_each_char$28.$$arity = 0); Opal.def(self, '$each_line', $String_each_line$30 = function $$each_line(separator) { var $iter = $String_each_line$30.$$p, block = $iter || nil, self = this; if ($gvars["/"] == null) $gvars["/"] = nil; if ($iter) $String_each_line$30.$$p = null; if ($iter) $String_each_line$30.$$p = null;; if (separator == null) { separator = $gvars["/"]; }; if ((block !== nil)) { } else { return self.$enum_for("each_line", separator) }; if (separator === nil) { Opal.yield1(block, self); return self; } separator = $$($nesting, 'Opal').$coerce_to(separator, $$($nesting, 'String'), "to_str") var a, i, n, length, chomped, trailing, splitted; if (separator.length === 0) { for (a = self.split(/(\n{2,})/), i = 0, n = a.length; i < n; i += 2) { if (a[i] || a[i + 1]) { var value = (a[i] || "") + (a[i + 1] || ""); Opal.yield1(block, self.$$cast(value)); } } return self; } chomped = self.$chomp(separator); trailing = self.length != chomped.length; splitted = chomped.split(separator); for (i = 0, length = splitted.length; i < length; i++) { if (i < length - 1 || trailing) { Opal.yield1(block, self.$$cast(splitted[i] + separator)); } else { Opal.yield1(block, self.$$cast(splitted[i])); } } ; return self; }, $String_each_line$30.$$arity = -1); Opal.def(self, '$empty?', $String_empty$ques$31 = function() { var self = this; return self.length === 0; }, $String_empty$ques$31.$$arity = 0); Opal.def(self, '$end_with?', $String_end_with$ques$32 = function($a) { var $post_args, suffixes, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); suffixes = $post_args;; for (var i = 0, length = suffixes.length; i < length; i++) { var suffix = $$($nesting, 'Opal').$coerce_to(suffixes[i], $$($nesting, 'String'), "to_str").$to_s(); if (self.length >= suffix.length && self.substr(self.length - suffix.length, suffix.length) == suffix) { return true; } } ; return false; }, $String_end_with$ques$32.$$arity = -1); Opal.alias(self, "equal?", "==="); Opal.def(self, '$gsub', $String_gsub$33 = function $$gsub(pattern, replacement) { var $iter = $String_gsub$33.$$p, block = $iter || nil, self = this; if ($iter) $String_gsub$33.$$p = null; if ($iter) $String_gsub$33.$$p = null;; ; if (replacement === undefined && block === nil) { return self.$enum_for("gsub", pattern); } var result = '', match_data = nil, index = 0, match, _replacement; if (pattern.$$is_regexp) { pattern = Opal.global_multiline_regexp(pattern); } else { pattern = $$($nesting, 'Opal').$coerce_to(pattern, $$($nesting, 'String'), "to_str"); pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gm'); } var lastIndex; while (true) { match = pattern.exec(self); if (match === null) { ($gvars["~"] = nil) result += self.slice(index); break; } match_data = $$($nesting, 'MatchData').$new(pattern, match); if (replacement === undefined) { lastIndex = pattern.lastIndex; _replacement = block(match[0]); pattern.lastIndex = lastIndex; // save and restore lastIndex } else if (replacement.$$is_hash) { _replacement = (replacement)['$[]'](match[0]).$to_s(); } else { if (!replacement.$$is_string) { replacement = $$($nesting, 'Opal').$coerce_to(replacement, $$($nesting, 'String'), "to_str"); } _replacement = replacement.replace(/([\\]+)([0-9+&`'])/g, function (original, slashes, command) { if (slashes.length % 2 === 0) { return original; } switch (command) { case "+": for (var i = match.length - 1; i > 0; i--) { if (match[i] !== undefined) { return slashes.slice(1) + match[i]; } } return ''; case "&": return slashes.slice(1) + match[0]; case "`": return slashes.slice(1) + self.slice(0, match.index); case "'": return slashes.slice(1) + self.slice(match.index + match[0].length); default: return slashes.slice(1) + (match[command] || ''); } }).replace(/\\\\/g, '\\'); } if (pattern.lastIndex === match.index) { result += (_replacement + self.slice(index, match.index + 1)) pattern.lastIndex += 1; } else { result += (self.slice(index, match.index) + _replacement) } index = pattern.lastIndex; } ($gvars["~"] = match_data) return self.$$cast(result); ; }, $String_gsub$33.$$arity = -2); Opal.def(self, '$hash', $String_hash$34 = function $$hash() { var self = this; return self.toString(); }, $String_hash$34.$$arity = 0); Opal.def(self, '$hex', $String_hex$35 = function $$hex() { var self = this; return self.$to_i(16) }, $String_hex$35.$$arity = 0); Opal.def(self, '$include?', $String_include$ques$36 = function(other) { var self = this; if (!other.$$is_string) { (other = $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'String'), "to_str")) } return self.indexOf(other) !== -1; }, $String_include$ques$36.$$arity = 1); Opal.def(self, '$index', $String_index$37 = function $$index(search, offset) { var self = this; ; var index, match, regex; if (offset === undefined) { offset = 0; } else { offset = $$($nesting, 'Opal').$coerce_to(offset, $$($nesting, 'Integer'), "to_int"); if (offset < 0) { offset += self.length; if (offset < 0) { return nil; } } } if (search.$$is_regexp) { regex = Opal.global_multiline_regexp(search); while (true) { match = regex.exec(self); if (match === null) { ($gvars["~"] = nil); index = -1; break; } if (match.index >= offset) { ($gvars["~"] = $$($nesting, 'MatchData').$new(regex, match)) index = match.index; break; } regex.lastIndex = match.index + 1; } } else { search = $$($nesting, 'Opal').$coerce_to(search, $$($nesting, 'String'), "to_str"); if (search.length === 0 && offset > self.length) { index = -1; } else { index = self.indexOf(search, offset); } } return index === -1 ? nil : index; ; }, $String_index$37.$$arity = -2); Opal.def(self, '$inspect', $String_inspect$38 = function $$inspect() { var self = this; var escapable = /[\\\"\x00-\x1f\u007F-\u009F\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, meta = { '\u0007': '\\a', '\u001b': '\\e', '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '\v': '\\v', '"' : '\\"', '\\': '\\\\' }, escaped = self.replace(escapable, function (chr) { return meta[chr] || '\\u' + ('0000' + chr.charCodeAt(0).toString(16).toUpperCase()).slice(-4); }); return '"' + escaped.replace(/\#[\$\@\{]/g, '\\$&') + '"'; }, $String_inspect$38.$$arity = 0); Opal.def(self, '$intern', $String_intern$39 = function $$intern() { var self = this; return self.toString(); }, $String_intern$39.$$arity = 0); Opal.def(self, '$lines', $String_lines$40 = function $$lines(separator) { var $iter = $String_lines$40.$$p, block = $iter || nil, self = this, e = nil; if ($gvars["/"] == null) $gvars["/"] = nil; if ($iter) $String_lines$40.$$p = null; if ($iter) $String_lines$40.$$p = null;; if (separator == null) { separator = $gvars["/"]; }; e = $send(self, 'each_line', [separator], block.$to_proc()); if ($truthy(block)) { return self } else { return e.$to_a() }; }, $String_lines$40.$$arity = -1); Opal.def(self, '$length', $String_length$41 = function $$length() { var self = this; return self.length; }, $String_length$41.$$arity = 0); Opal.def(self, '$ljust', $String_ljust$42 = function $$ljust(width, padstr) { var self = this; if (padstr == null) { padstr = " "; }; width = $$($nesting, 'Opal').$coerce_to(width, $$($nesting, 'Integer'), "to_int"); padstr = $$($nesting, 'Opal').$coerce_to(padstr, $$($nesting, 'String'), "to_str").$to_s(); if ($truthy(padstr['$empty?']())) { self.$raise($$($nesting, 'ArgumentError'), "zero width padding")}; if ($truthy(width <= self.length)) { return self}; var index = -1, result = ""; width -= self.length; while (++index < width) { result += padstr; } return self.$$cast(self + result.slice(0, width)); ; }, $String_ljust$42.$$arity = -2); Opal.def(self, '$lstrip', $String_lstrip$43 = function $$lstrip() { var self = this; return self.replace(/^\s*/, ''); }, $String_lstrip$43.$$arity = 0); Opal.def(self, '$ascii_only?', $String_ascii_only$ques$44 = function() { var self = this; if (self.$encoding()['$==']($$$($$($nesting, 'Encoding'), 'UTF_16BE'))) { return false}; return /^[\x00-\x7F]*$/.test(self);; }, $String_ascii_only$ques$44.$$arity = 0); Opal.def(self, '$match', $String_match$45 = function $$match(pattern, pos) { var $iter = $String_match$45.$$p, block = $iter || nil, $a, self = this; if ($iter) $String_match$45.$$p = null; if ($iter) $String_match$45.$$p = null;; ; if ($truthy(($truthy($a = $$($nesting, 'String')['$==='](pattern)) ? $a : pattern['$respond_to?']("to_str")))) { pattern = $$($nesting, 'Regexp').$new(pattern.$to_str())}; if ($truthy($$($nesting, 'Regexp')['$==='](pattern))) { } else { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + (pattern.$class()) + " (expected Regexp)") }; return $send(pattern, 'match', [self, pos], block.$to_proc()); }, $String_match$45.$$arity = -2); Opal.def(self, '$match?', $String_match$ques$46 = function(pattern, pos) { var $a, self = this; ; if ($truthy(($truthy($a = $$($nesting, 'String')['$==='](pattern)) ? $a : pattern['$respond_to?']("to_str")))) { pattern = $$($nesting, 'Regexp').$new(pattern.$to_str())}; if ($truthy($$($nesting, 'Regexp')['$==='](pattern))) { } else { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + (pattern.$class()) + " (expected Regexp)") }; return pattern['$match?'](self, pos); }, $String_match$ques$46.$$arity = -2); Opal.def(self, '$next', $String_next$47 = function $$next() { var self = this; var i = self.length; if (i === 0) { return self.$$cast(''); } var result = self; var first_alphanum_char_index = self.search(/[a-zA-Z0-9]/); var carry = false; var code; while (i--) { code = self.charCodeAt(i); if ((code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122)) { switch (code) { case 57: carry = true; code = 48; break; case 90: carry = true; code = 65; break; case 122: carry = true; code = 97; break; default: carry = false; code += 1; } } else { if (first_alphanum_char_index === -1) { if (code === 255) { carry = true; code = 0; } else { carry = false; code += 1; } } else { carry = true; } } result = result.slice(0, i) + String.fromCharCode(code) + result.slice(i + 1); if (carry && (i === 0 || i === first_alphanum_char_index)) { switch (code) { case 65: break; case 97: break; default: code += 1; } if (i === 0) { result = String.fromCharCode(code) + result; } else { result = result.slice(0, i) + String.fromCharCode(code) + result.slice(i); } carry = false; } if (!carry) { break; } } return self.$$cast(result); }, $String_next$47.$$arity = 0); Opal.def(self, '$oct', $String_oct$48 = function $$oct() { var self = this; var result, string = self, radix = 8; if (/^\s*_/.test(string)) { return 0; } string = string.replace(/^(\s*[+-]?)(0[bodx]?)(.+)$/i, function (original, head, flag, tail) { switch (tail.charAt(0)) { case '+': case '-': return original; case '0': if (tail.charAt(1) === 'x' && flag === '0x') { return original; } } switch (flag) { case '0b': radix = 2; break; case '0': case '0o': radix = 8; break; case '0d': radix = 10; break; case '0x': radix = 16; break; } return head + tail; }); result = parseInt(string.replace(/_(?!_)/g, ''), radix); return isNaN(result) ? 0 : result; }, $String_oct$48.$$arity = 0); Opal.def(self, '$ord', $String_ord$49 = function $$ord() { var self = this; return self.charCodeAt(0); }, $String_ord$49.$$arity = 0); Opal.def(self, '$partition', $String_partition$50 = function $$partition(sep) { var self = this; var i, m; if (sep.$$is_regexp) { m = sep.exec(self); if (m === null) { i = -1; } else { $$($nesting, 'MatchData').$new(sep, m); sep = m[0]; i = m.index; } } else { sep = $$($nesting, 'Opal').$coerce_to(sep, $$($nesting, 'String'), "to_str"); i = self.indexOf(sep); } if (i === -1) { return [self, '', '']; } return [ self.slice(0, i), self.slice(i, i + sep.length), self.slice(i + sep.length) ]; }, $String_partition$50.$$arity = 1); Opal.def(self, '$reverse', $String_reverse$51 = function $$reverse() { var self = this; return self.split('').reverse().join(''); }, $String_reverse$51.$$arity = 0); Opal.def(self, '$rindex', $String_rindex$52 = function $$rindex(search, offset) { var self = this; ; var i, m, r, _m; if (offset === undefined) { offset = self.length; } else { offset = $$($nesting, 'Opal').$coerce_to(offset, $$($nesting, 'Integer'), "to_int"); if (offset < 0) { offset += self.length; if (offset < 0) { return nil; } } } if (search.$$is_regexp) { m = null; r = Opal.global_multiline_regexp(search); while (true) { _m = r.exec(self); if (_m === null || _m.index > offset) { break; } m = _m; r.lastIndex = m.index + 1; } if (m === null) { ($gvars["~"] = nil) i = -1; } else { $$($nesting, 'MatchData').$new(r, m); i = m.index; } } else { search = $$($nesting, 'Opal').$coerce_to(search, $$($nesting, 'String'), "to_str"); i = self.lastIndexOf(search, offset); } return i === -1 ? nil : i; ; }, $String_rindex$52.$$arity = -2); Opal.def(self, '$rjust', $String_rjust$53 = function $$rjust(width, padstr) { var self = this; if (padstr == null) { padstr = " "; }; width = $$($nesting, 'Opal').$coerce_to(width, $$($nesting, 'Integer'), "to_int"); padstr = $$($nesting, 'Opal').$coerce_to(padstr, $$($nesting, 'String'), "to_str").$to_s(); if ($truthy(padstr['$empty?']())) { self.$raise($$($nesting, 'ArgumentError'), "zero width padding")}; if ($truthy(width <= self.length)) { 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 self.$$cast(result + padstr.slice(0, remaining) + self); ; }, $String_rjust$53.$$arity = -2); Opal.def(self, '$rpartition', $String_rpartition$54 = function $$rpartition(sep) { var self = this; var i, m, r, _m; if (sep.$$is_regexp) { m = null; r = Opal.global_multiline_regexp(sep); while (true) { _m = r.exec(self); if (_m === null) { break; } m = _m; r.lastIndex = m.index + 1; } if (m === null) { i = -1; } else { $$($nesting, 'MatchData').$new(r, m); sep = m[0]; i = m.index; } } else { sep = $$($nesting, 'Opal').$coerce_to(sep, $$($nesting, 'String'), "to_str"); i = self.lastIndexOf(sep); } if (i === -1) { return ['', '', self]; } return [ self.slice(0, i), self.slice(i, i + sep.length), self.slice(i + sep.length) ]; }, $String_rpartition$54.$$arity = 1); Opal.def(self, '$rstrip', $String_rstrip$55 = function $$rstrip() { var self = this; return self.replace(/[\s\u0000]*$/, ''); }, $String_rstrip$55.$$arity = 0); Opal.def(self, '$scan', $String_scan$56 = function $$scan(pattern) { var $iter = $String_scan$56.$$p, block = $iter || nil, self = this; if ($iter) $String_scan$56.$$p = null; if ($iter) $String_scan$56.$$p = null;; var result = [], match_data = nil, match; if (pattern.$$is_regexp) { pattern = Opal.global_multiline_regexp(pattern); } else { pattern = $$($nesting, 'Opal').$coerce_to(pattern, $$($nesting, 'String'), "to_str"); pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gm'); } while ((match = pattern.exec(self)) != null) { match_data = $$($nesting, 'MatchData').$new(pattern, match); if (block === nil) { match.length == 1 ? result.push(match[0]) : result.push((match_data).$captures()); } else { match.length == 1 ? block(match[0]) : block.call(self, (match_data).$captures()); } if (pattern.lastIndex === match.index) { pattern.lastIndex += 1; } } ($gvars["~"] = match_data) return (block !== nil ? self : result); ; }, $String_scan$56.$$arity = 1); Opal.alias(self, "size", "length"); Opal.alias(self, "slice", "[]"); Opal.def(self, '$split', $String_split$57 = function $$split(pattern, limit) { var $a, self = this; if ($gvars[";"] == null) $gvars[";"] = nil; ; ; if (self.length === 0) { return []; } if (limit === undefined) { limit = 0; } else { limit = $$($nesting, 'Opal')['$coerce_to!'](limit, $$($nesting, 'Integer'), "to_int"); if (limit === 1) { return [self]; } } if (pattern === undefined || pattern === nil) { pattern = ($truthy($a = $gvars[";"]) ? $a : " "); } var result = [], string = self.toString(), index = 0, match, i, ii; if (pattern.$$is_regexp) { pattern = Opal.global_multiline_regexp(pattern); } else { pattern = $$($nesting, 'Opal').$coerce_to(pattern, $$($nesting, 'String'), "to_str").$to_s(); if (pattern === ' ') { pattern = /\s+/gm; string = string.replace(/^\s+/, ''); } else { pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gm'); } } result = string.split(pattern); if (result.length === 1 && result[0] === string) { return [self.$$cast(result[0])]; } while ((i = result.indexOf(undefined)) !== -1) { result.splice(i, 1); } function castResult() { for (i = 0; i < result.length; i++) { result[i] = self.$$cast(result[i]); } } if (limit === 0) { while (result[result.length - 1] === '') { result.length -= 1; } castResult(); return result; } match = pattern.exec(string); if (limit < 0) { if (match !== null && match[0] === '' && pattern.source.indexOf('(?=') === -1) { for (i = 0, ii = match.length; i < ii; i++) { result.push(''); } } castResult(); return result; } if (match !== null && match[0] === '') { result.splice(limit - 1, result.length - 1, result.slice(limit - 1).join('')); castResult(); return result; } if (limit >= result.length) { castResult(); return result; } i = 0; while (match !== null) { i++; index = pattern.lastIndex; if (i + 1 === limit) { break; } match = pattern.exec(string); } result.splice(limit - 1, result.length - 1, string.slice(index)); castResult(); return result; ; }, $String_split$57.$$arity = -1); Opal.def(self, '$squeeze', $String_squeeze$58 = function $$squeeze($a) { var $post_args, sets, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); sets = $post_args;; if (sets.length === 0) { return self.$$cast(self.replace(/(.)\1+/g, '$1')); } var char_class = char_class_from_char_sets(sets); if (char_class === null) { return self; } return self.$$cast(self.replace(new RegExp('(' + char_class + ')\\1+', 'g'), '$1')); ; }, $String_squeeze$58.$$arity = -1); Opal.def(self, '$start_with?', $String_start_with$ques$59 = function($a) { var $post_args, prefixes, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); prefixes = $post_args;; for (var i = 0, length = prefixes.length; i < length; i++) { var prefix = $$($nesting, 'Opal').$coerce_to(prefixes[i], $$($nesting, 'String'), "to_str").$to_s(); if (self.indexOf(prefix) === 0) { return true; } } return false; ; }, $String_start_with$ques$59.$$arity = -1); Opal.def(self, '$strip', $String_strip$60 = function $$strip() { var self = this; return self.replace(/^\s*/, '').replace(/[\s\u0000]*$/, ''); }, $String_strip$60.$$arity = 0); Opal.def(self, '$sub', $String_sub$61 = function $$sub(pattern, replacement) { var $iter = $String_sub$61.$$p, block = $iter || nil, self = this; if ($iter) $String_sub$61.$$p = null; if ($iter) $String_sub$61.$$p = null;; ; if (!pattern.$$is_regexp) { pattern = $$($nesting, 'Opal').$coerce_to(pattern, $$($nesting, 'String'), "to_str"); pattern = new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')); } var result, match = pattern.exec(self); if (match === null) { ($gvars["~"] = nil) result = self.toString(); } else { $$($nesting, 'MatchData').$new(pattern, match) if (replacement === undefined) { if (block === nil) { self.$raise($$($nesting, 'ArgumentError'), "wrong number of arguments (1 for 2)") } result = self.slice(0, match.index) + block(match[0]) + self.slice(match.index + match[0].length); } else if (replacement.$$is_hash) { result = self.slice(0, match.index) + (replacement)['$[]'](match[0]).$to_s() + self.slice(match.index + match[0].length); } else { replacement = $$($nesting, 'Opal').$coerce_to(replacement, $$($nesting, 'String'), "to_str"); replacement = replacement.replace(/([\\]+)([0-9+&`'])/g, function (original, slashes, command) { if (slashes.length % 2 === 0) { return original; } switch (command) { case "+": for (var i = match.length - 1; i > 0; i--) { if (match[i] !== undefined) { return slashes.slice(1) + match[i]; } } return ''; case "&": return slashes.slice(1) + match[0]; case "`": return slashes.slice(1) + self.slice(0, match.index); case "'": return slashes.slice(1) + self.slice(match.index + match[0].length); default: return slashes.slice(1) + (match[command] || ''); } }).replace(/\\\\/g, '\\'); result = self.slice(0, match.index) + replacement + self.slice(match.index + match[0].length); } } return self.$$cast(result); ; }, $String_sub$61.$$arity = -2); Opal.alias(self, "succ", "next"); Opal.def(self, '$sum', $String_sum$62 = function $$sum(n) { var self = this; if (n == null) { n = 16; }; n = $$($nesting, 'Opal').$coerce_to(n, $$($nesting, 'Integer'), "to_int"); var result = 0, length = self.length, i = 0; for (; i < length; i++) { result += self.charCodeAt(i); } if (n <= 0) { return result; } return result & (Math.pow(2, n) - 1); ; }, $String_sum$62.$$arity = -1); Opal.def(self, '$swapcase', $String_swapcase$63 = function $$swapcase() { 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); }, $String_swapcase$63.$$arity = 0); Opal.def(self, '$to_f', $String_to_f$64 = function $$to_f() { 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; } }, $String_to_f$64.$$arity = 0); Opal.def(self, '$to_i', $String_to_i$65 = function $$to_i(base) { var self = this; if (base == null) { base = 10; }; var result, string = self.toLowerCase(), radix = $$($nesting, 'Opal').$coerce_to(base, $$($nesting, 'Integer'), "to_int"); if (radix === 1 || radix < 0 || radix > 36) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid radix " + (radix)) } if (/^\s*_/.test(string)) { return 0; } string = string.replace(/^(\s*[+-]?)(0[bodx]?)(.+)$/, function (original, head, flag, tail) { switch (tail.charAt(0)) { case '+': case '-': return original; case '0': if (tail.charAt(1) === 'x' && flag === '0x' && (radix === 0 || radix === 16)) { return original; } } switch (flag) { case '0b': if (radix === 0 || radix === 2) { radix = 2; return head + tail; } break; case '0': case '0o': if (radix === 0 || radix === 8) { radix = 8; return head + tail; } break; case '0d': if (radix === 0 || radix === 10) { radix = 10; return head + tail; } break; case '0x': if (radix === 0 || radix === 16) { radix = 16; return head + tail; } break; } return original }); result = parseInt(string.replace(/_(?!_)/g, ''), radix); return isNaN(result) ? 0 : result; ; }, $String_to_i$65.$$arity = -1); Opal.def(self, '$to_proc', $String_to_proc$66 = function $$to_proc() { var $$67, $iter = $String_to_proc$66.$$p, $yield = $iter || nil, self = this, method_name = nil; if ($iter) $String_to_proc$66.$$p = null; method_name = $rb_plus("$", self.valueOf()); return $send(self, 'proc', [], ($$67 = function($a){var self = $$67.$$s || this, $iter = $$67.$$p, block = $iter || nil, $post_args, args; if ($iter) $$67.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if (args.length === 0) { self.$raise($$($nesting, 'ArgumentError'), "no receiver given") } var recv = args[0]; if (recv == null) recv = nil; var body = recv[method_name]; if (!body) { return recv.$method_missing.apply(recv, args); } if (typeof block === 'function') { body.$$p = block; } if (args.length === 1) { return body.call(recv); } else { return body.apply(recv, args.slice(1)); } ;}, $$67.$$s = self, $$67.$$arity = -1, $$67)); }, $String_to_proc$66.$$arity = 0); Opal.def(self, '$to_s', $String_to_s$68 = function $$to_s() { var self = this; return self.toString(); }, $String_to_s$68.$$arity = 0); Opal.alias(self, "to_str", "to_s"); Opal.alias(self, "to_sym", "intern"); Opal.def(self, '$tr', $String_tr$69 = function $$tr(from, to) { var self = this; from = $$($nesting, 'Opal').$coerce_to(from, $$($nesting, 'String'), "to_str").$to_s(); to = $$($nesting, 'Opal').$coerce_to(to, $$($nesting, 'String'), "to_str").$to_s(); if (from.length == 0 || from === to) { return self; } var i, in_range, c, ch, start, end, length; 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] === '^' && from_chars.length > 1) { inverse = true; from_chars.shift(); global_sub = to_chars[to_length - 1] from_length -= 1; } var from_chars_expanded = []; var last_from = null; in_range = false; for (i = 0; i < from_length; i++) { 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) { start = last_from.charCodeAt(0); end = ch.charCodeAt(0); if (start > end) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") } for (c = start + 1; 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 (i = 0; i < from_length; i++) { subs[from_chars[i]] = true; } } else { if (to_length > 0) { var to_chars_expanded = []; var last_to = null; in_range = false; for (i = 0; i < to_length; i++) { ch = to_chars[i]; if (last_to == null) { last_to = 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) { start = last_to.charCodeAt(0); end = ch.charCodeAt(0); if (start > end) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") } for (c = start + 1; c < end; c++) { to_chars_expanded.push(String.fromCharCode(c)); } to_chars_expanded.push(ch); in_range = null; last_to = 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 (i = 0; i < length_diff; i++) { to_chars.push(pad_char); } } for (i = 0; i < from_length; i++) { subs[from_chars[i]] = to_chars[i]; } } var new_str = '' for (i = 0, length = self.length; i < length; i++) { 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 self.$$cast(new_str); ; }, $String_tr$69.$$arity = 2); Opal.def(self, '$tr_s', $String_tr_s$70 = function $$tr_s(from, to) { var self = this; from = $$($nesting, 'Opal').$coerce_to(from, $$($nesting, 'String'), "to_str").$to_s(); to = $$($nesting, 'Opal').$coerce_to(to, $$($nesting, 'String'), "to_str").$to_s(); if (from.length == 0) { return self; } var i, in_range, c, ch, start, end, length; 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] === '^' && from_chars.length > 1) { inverse = true; from_chars.shift(); global_sub = to_chars[to_length - 1] from_length -= 1; } var from_chars_expanded = []; var last_from = null; in_range = false; for (i = 0; i < from_length; i++) { 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) { start = last_from.charCodeAt(0); end = ch.charCodeAt(0); if (start > end) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") } for (c = start + 1; 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 (i = 0; i < from_length; i++) { subs[from_chars[i]] = true; } } else { if (to_length > 0) { var to_chars_expanded = []; var last_to = null; in_range = false; for (i = 0; i < to_length; i++) { 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) { start = last_from.charCodeAt(0); end = ch.charCodeAt(0); if (start > end) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid range \"" + (String.fromCharCode(start)) + "-" + (String.fromCharCode(end)) + "\" in string transliteration") } for (c = start + 1; 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 (i = 0; i < length_diff; i++) { to_chars.push(pad_char); } } for (i = 0; i < from_length; i++) { subs[from_chars[i]] = to_chars[i]; } } var new_str = '' var last_substitute = null for (i = 0, length = self.length; i < length; i++) { 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 self.$$cast(new_str); ; }, $String_tr_s$70.$$arity = 2); Opal.def(self, '$upcase', $String_upcase$71 = function $$upcase() { var self = this; return self.$$cast(self.toUpperCase()); }, $String_upcase$71.$$arity = 0); Opal.def(self, '$upto', $String_upto$72 = function $$upto(stop, excl) { var $iter = $String_upto$72.$$p, block = $iter || nil, self = this; if ($iter) $String_upto$72.$$p = null; if ($iter) $String_upto$72.$$p = null;; if (excl == null) { excl = false; }; if ((block !== nil)) { } else { return self.$enum_for("upto", stop, excl) }; stop = $$($nesting, 'Opal').$coerce_to(stop, $$($nesting, 'String'), "to_str"); var a, b, s = self.toString(); if (s.length === 1 && stop.length === 1) { a = s.charCodeAt(0); b = stop.charCodeAt(0); while (a <= b) { if (excl && a === b) { break; } block(String.fromCharCode(a)); a += 1; } } else if (parseInt(s, 10).toString() === s && parseInt(stop, 10).toString() === stop) { a = parseInt(s, 10); b = parseInt(stop, 10); while (a <= b) { if (excl && a === b) { break; } block(a.toString()); a += 1; } } else { while (s.length <= stop.length && s <= stop) { if (excl && s === stop) { break; } block(s); s = (s).$succ(); } } return self; ; }, $String_upto$72.$$arity = -2); function char_class_from_char_sets(sets) { function explode_sequences_in_character_set(set) { var result = '', i, len = set.length, curr_char, skip_next_dash, char_code_from, char_code_upto, char_code; for (i = 0; i < len; i++) { curr_char = set.charAt(i); if (curr_char === '-' && i > 0 && i < (len - 1) && !skip_next_dash) { char_code_from = set.charCodeAt(i - 1); char_code_upto = set.charCodeAt(i + 1); if (char_code_from > char_code_upto) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid range \"" + (char_code_from) + "-" + (char_code_upto) + "\" in string transliteration") } for (char_code = char_code_from + 1; char_code < char_code_upto + 1; char_code++) { result += String.fromCharCode(char_code); } skip_next_dash = true; i++; } else { skip_next_dash = (curr_char === '\\'); result += curr_char; } } return result; } function intersection(setA, setB) { if (setA.length === 0) { return setB; } var result = '', i, len = setA.length, chr; for (i = 0; i < len; i++) { chr = setA.charAt(i); if (setB.indexOf(chr) !== -1) { result += chr; } } return result; } var i, len, set, neg, chr, tmp, pos_intersection = '', neg_intersection = ''; for (i = 0, len = sets.length; i < len; i++) { set = $$($nesting, 'Opal').$coerce_to(sets[i], $$($nesting, 'String'), "to_str"); neg = (set.charAt(0) === '^' && set.length > 1); set = explode_sequences_in_character_set(neg ? set.slice(1) : set); if (neg) { neg_intersection = intersection(neg_intersection, set); } else { pos_intersection = intersection(pos_intersection, set); } } if (pos_intersection.length > 0 && neg_intersection.length > 0) { tmp = ''; for (i = 0, len = pos_intersection.length; i < len; i++) { chr = pos_intersection.charAt(i); if (neg_intersection.indexOf(chr) === -1) { tmp += chr; } } pos_intersection = tmp; neg_intersection = ''; } if (pos_intersection.length > 0) { return '[' + $$($nesting, 'Regexp').$escape(pos_intersection) + ']'; } if (neg_intersection.length > 0) { return '[^' + $$($nesting, 'Regexp').$escape(neg_intersection) + ']'; } return null; } ; Opal.def(self, '$instance_variables', $String_instance_variables$73 = function $$instance_variables() { var self = this; return [] }, $String_instance_variables$73.$$arity = 0); Opal.defs(self, '$_load', $String__load$74 = function $$_load($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self, 'new', Opal.to_a(args)); }, $String__load$74.$$arity = -1); Opal.def(self, '$unicode_normalize', $String_unicode_normalize$75 = function $$unicode_normalize(form) { var self = this; ; return self.toString();; }, $String_unicode_normalize$75.$$arity = -1); Opal.def(self, '$unicode_normalized?', $String_unicode_normalized$ques$76 = function(form) { var self = this; ; return true; }, $String_unicode_normalized$ques$76.$$arity = -1); Opal.def(self, '$unpack', $String_unpack$77 = function $$unpack(format) { var self = this; return self.$raise("To use String#unpack, you must first require 'corelib/string/unpack'.") }, $String_unpack$77.$$arity = 1); return (Opal.def(self, '$unpack1', $String_unpack1$78 = function $$unpack1(format) { var self = this; return self.$raise("To use String#unpack1, you must first require 'corelib/string/unpack'.") }, $String_unpack1$78.$$arity = 1), nil) && 'unpack1'; })($nesting[0], String, $nesting); return Opal.const_set($nesting[0], 'Symbol', $$($nesting, 'String')); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/enumerable"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_le(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy, $send = Opal.send, $falsy = Opal.falsy, $hash2 = Opal.hash2, $lambda = Opal.lambda; Opal.add_stubs(['$each', '$public_send', '$destructure', '$to_enum', '$enumerator_size', '$new', '$yield', '$raise', '$slice_when', '$!', '$enum_for', '$flatten', '$map', '$warn', '$proc', '$==', '$nil?', '$respond_to?', '$coerce_to!', '$>', '$*', '$coerce_to', '$try_convert', '$<', '$+', '$-', '$ceil', '$/', '$size', '$__send__', '$length', '$<=', '$[]', '$push', '$<<', '$[]=', '$===', '$inspect', '$<=>', '$first', '$reverse', '$sort', '$to_proc', '$compare', '$call', '$dup', '$to_a', '$sort!', '$map!', '$key?', '$values', '$zip']); return (function($base, $parent_nesting) { var self = $module($base, 'Enumerable'); var $nesting = [self].concat($parent_nesting), $Enumerable_all$ques$1, $Enumerable_any$ques$5, $Enumerable_chunk$9, $Enumerable_chunk_while$12, $Enumerable_collect$14, $Enumerable_collect_concat$16, $Enumerable_count$19, $Enumerable_cycle$23, $Enumerable_detect$25, $Enumerable_drop$27, $Enumerable_drop_while$28, $Enumerable_each_cons$29, $Enumerable_each_entry$31, $Enumerable_each_slice$33, $Enumerable_each_with_index$35, $Enumerable_each_with_object$37, $Enumerable_entries$39, $Enumerable_find_all$40, $Enumerable_find_index$42, $Enumerable_first$45, $Enumerable_grep$48, $Enumerable_grep_v$50, $Enumerable_group_by$52, $Enumerable_include$ques$54, $Enumerable_inject$56, $Enumerable_lazy$57, $Enumerable_enumerator_size$59, $Enumerable_max$60, $Enumerable_max_by$61, $Enumerable_min$63, $Enumerable_min_by$64, $Enumerable_minmax$66, $Enumerable_minmax_by$68, $Enumerable_none$ques$69, $Enumerable_one$ques$73, $Enumerable_partition$77, $Enumerable_reject$79, $Enumerable_reverse_each$81, $Enumerable_slice_before$83, $Enumerable_slice_after$85, $Enumerable_slice_when$88, $Enumerable_sort$90, $Enumerable_sort_by$92, $Enumerable_sum$97, $Enumerable_take$99, $Enumerable_take_while$100, $Enumerable_uniq$102, $Enumerable_zip$104; function comparableForPattern(value) { if (value.length === 0) { value = [nil]; } if (value.length > 1) { value = [value]; } return value; } ; Opal.def(self, '$all?', $Enumerable_all$ques$1 = function(pattern) {try { var $iter = $Enumerable_all$ques$1.$$p, block = $iter || nil, $$2, $$3, $$4, self = this; if ($iter) $Enumerable_all$ques$1.$$p = null; if ($iter) $Enumerable_all$ques$1.$$p = null;; ; if ($truthy(pattern !== undefined)) { $send(self, 'each', [], ($$2 = function($a){var self = $$2.$$s || this, $post_args, value, comparable = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; comparable = comparableForPattern(value); if ($truthy($send(pattern, 'public_send', ["==="].concat(Opal.to_a(comparable))))) { return nil } else { Opal.ret(false) };}, $$2.$$s = self, $$2.$$arity = -1, $$2)) } else if ((block !== nil)) { $send(self, 'each', [], ($$3 = function($a){var self = $$3.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy(Opal.yieldX(block, Opal.to_a(value)))) { return nil } else { Opal.ret(false) };}, $$3.$$s = self, $$3.$$arity = -1, $$3)) } else { $send(self, 'each', [], ($$4 = function($a){var self = $$4.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy($$($nesting, 'Opal').$destructure(value))) { return nil } else { Opal.ret(false) };}, $$4.$$s = self, $$4.$$arity = -1, $$4)) }; return true; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_all$ques$1.$$arity = -1); Opal.def(self, '$any?', $Enumerable_any$ques$5 = function(pattern) {try { var $iter = $Enumerable_any$ques$5.$$p, block = $iter || nil, $$6, $$7, $$8, self = this; if ($iter) $Enumerable_any$ques$5.$$p = null; if ($iter) $Enumerable_any$ques$5.$$p = null;; ; if ($truthy(pattern !== undefined)) { $send(self, 'each', [], ($$6 = function($a){var self = $$6.$$s || this, $post_args, value, comparable = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; comparable = comparableForPattern(value); if ($truthy($send(pattern, 'public_send', ["==="].concat(Opal.to_a(comparable))))) { Opal.ret(true) } else { return nil };}, $$6.$$s = self, $$6.$$arity = -1, $$6)) } else if ((block !== nil)) { $send(self, 'each', [], ($$7 = function($a){var self = $$7.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy(Opal.yieldX(block, Opal.to_a(value)))) { Opal.ret(true) } else { return nil };}, $$7.$$s = self, $$7.$$arity = -1, $$7)) } else { $send(self, 'each', [], ($$8 = function($a){var self = $$8.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy($$($nesting, 'Opal').$destructure(value))) { Opal.ret(true) } else { return nil };}, $$8.$$s = self, $$8.$$arity = -1, $$8)) }; return false; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_any$ques$5.$$arity = -1); Opal.def(self, '$chunk', $Enumerable_chunk$9 = function $$chunk() { var $iter = $Enumerable_chunk$9.$$p, block = $iter || nil, $$10, $$11, self = this; if ($iter) $Enumerable_chunk$9.$$p = null; if ($iter) $Enumerable_chunk$9.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'to_enum', ["chunk"], ($$10 = function(){var self = $$10.$$s || this; return self.$enumerator_size()}, $$10.$$s = self, $$10.$$arity = 0, $$10)) }; return $send($$$('::', 'Enumerator'), 'new', [], ($$11 = function(yielder){var self = $$11.$$s || this; if (yielder == null) { yielder = nil; }; var previous = nil, accumulate = []; function releaseAccumulate() { if (accumulate.length > 0) { yielder.$yield(previous, accumulate) } } self.$each.$$p = function(value) { var key = Opal.yield1(block, value); if (key === nil) { releaseAccumulate(); accumulate = []; previous = nil; } else { if (previous === nil || previous === key) { accumulate.push(value); } else { releaseAccumulate(); accumulate = [value]; } previous = key; } } self.$each(); releaseAccumulate(); ;}, $$11.$$s = self, $$11.$$arity = 1, $$11)); }, $Enumerable_chunk$9.$$arity = 0); Opal.def(self, '$chunk_while', $Enumerable_chunk_while$12 = function $$chunk_while() { var $iter = $Enumerable_chunk_while$12.$$p, block = $iter || nil, $$13, self = this; if ($iter) $Enumerable_chunk_while$12.$$p = null; if ($iter) $Enumerable_chunk_while$12.$$p = null;; if ((block !== nil)) { } else { self.$raise($$($nesting, 'ArgumentError'), "no block given") }; return $send(self, 'slice_when', [], ($$13 = function(before, after){var self = $$13.$$s || this; if (before == null) { before = nil; }; if (after == null) { after = nil; }; return Opal.yieldX(block, [before, after])['$!']();}, $$13.$$s = self, $$13.$$arity = 2, $$13)); }, $Enumerable_chunk_while$12.$$arity = 0); Opal.def(self, '$collect', $Enumerable_collect$14 = function $$collect() { var $iter = $Enumerable_collect$14.$$p, block = $iter || nil, $$15, self = this; if ($iter) $Enumerable_collect$14.$$p = null; if ($iter) $Enumerable_collect$14.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["collect"], ($$15 = function(){var self = $$15.$$s || this; return self.$enumerator_size()}, $$15.$$s = self, $$15.$$arity = 0, $$15)) }; var result = []; self.$each.$$p = function() { var value = Opal.yieldX(block, arguments); result.push(value); }; self.$each(); return result; ; }, $Enumerable_collect$14.$$arity = 0); Opal.def(self, '$collect_concat', $Enumerable_collect_concat$16 = function $$collect_concat() { var $iter = $Enumerable_collect_concat$16.$$p, block = $iter || nil, $$17, $$18, self = this; if ($iter) $Enumerable_collect_concat$16.$$p = null; if ($iter) $Enumerable_collect_concat$16.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["collect_concat"], ($$17 = function(){var self = $$17.$$s || this; return self.$enumerator_size()}, $$17.$$s = self, $$17.$$arity = 0, $$17)) }; return $send(self, 'map', [], ($$18 = function(item){var self = $$18.$$s || this; if (item == null) { item = nil; }; return Opal.yield1(block, item);;}, $$18.$$s = self, $$18.$$arity = 1, $$18)).$flatten(1); }, $Enumerable_collect_concat$16.$$arity = 0); Opal.def(self, '$count', $Enumerable_count$19 = function $$count(object) { var $iter = $Enumerable_count$19.$$p, block = $iter || nil, $$20, $$21, $$22, self = this, result = nil; if ($iter) $Enumerable_count$19.$$p = null; if ($iter) $Enumerable_count$19.$$p = null;; ; result = 0; if (object != null && block !== nil) { self.$warn("warning: given block not used") } ; if ($truthy(object != null)) { block = $send(self, 'proc', [], ($$20 = function($a){var self = $$20.$$s || this, $post_args, args; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $$($nesting, 'Opal').$destructure(args)['$=='](object);}, $$20.$$s = self, $$20.$$arity = -1, $$20)) } else if ($truthy(block['$nil?']())) { block = $send(self, 'proc', [], ($$21 = function(){var self = $$21.$$s || this; return true}, $$21.$$s = self, $$21.$$arity = 0, $$21))}; $send(self, 'each', [], ($$22 = function($a){var self = $$22.$$s || this, $post_args, args; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(Opal.yieldX(block, args))) { return result++; } else { return nil };}, $$22.$$s = self, $$22.$$arity = -1, $$22)); return result; }, $Enumerable_count$19.$$arity = -1); Opal.def(self, '$cycle', $Enumerable_cycle$23 = function $$cycle(n) { var $iter = $Enumerable_cycle$23.$$p, block = $iter || nil, $$24, self = this; if ($iter) $Enumerable_cycle$23.$$p = null; if ($iter) $Enumerable_cycle$23.$$p = null;; if (n == null) { n = nil; }; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["cycle", n], ($$24 = function(){var self = $$24.$$s || this; if ($truthy(n['$nil?']())) { if ($truthy(self['$respond_to?']("size"))) { return $$$($$($nesting, 'Float'), 'INFINITY') } else { return nil } } else { n = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_gt(n, 0))) { return $rb_times(self.$enumerator_size(), n) } else { return 0 }; }}, $$24.$$s = self, $$24.$$arity = 0, $$24)) }; if ($truthy(n['$nil?']())) { } else { n = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if ($truthy(n <= 0)) { return nil}; }; var result, all = [], i, length, value; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); all.push(param); } self.$each(); if (result !== undefined) { return result; } if (all.length === 0) { return nil; } if (n === nil) { while (true) { for (i = 0, length = all.length; i < length; i++) { value = Opal.yield1(block, all[i]); } } } else { while (n > 1) { for (i = 0, length = all.length; i < length; i++) { value = Opal.yield1(block, all[i]); } n--; } } ; }, $Enumerable_cycle$23.$$arity = -1); Opal.def(self, '$detect', $Enumerable_detect$25 = function $$detect(ifnone) {try { var $iter = $Enumerable_detect$25.$$p, block = $iter || nil, $$26, self = this; if ($iter) $Enumerable_detect$25.$$p = null; if ($iter) $Enumerable_detect$25.$$p = null;; ; if ((block !== nil)) { } else { return self.$enum_for("detect", ifnone) }; $send(self, 'each', [], ($$26 = function($a){var self = $$26.$$s || this, $post_args, args, value = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; value = $$($nesting, 'Opal').$destructure(args); if ($truthy(Opal.yield1(block, value))) { Opal.ret(value) } else { return nil };}, $$26.$$s = self, $$26.$$arity = -1, $$26)); if (ifnone !== undefined) { if (typeof(ifnone) === 'function') { return ifnone(); } else { return ifnone; } } ; return nil; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_detect$25.$$arity = -1); Opal.def(self, '$drop', $Enumerable_drop$27 = function $$drop(number) { var self = this; number = $$($nesting, 'Opal').$coerce_to(number, $$($nesting, 'Integer'), "to_int"); if ($truthy(number < 0)) { self.$raise($$($nesting, 'ArgumentError'), "attempt to drop negative size")}; var result = [], current = 0; self.$each.$$p = function() { if (number <= current) { result.push($$($nesting, 'Opal').$destructure(arguments)); } current++; }; self.$each() return result; ; }, $Enumerable_drop$27.$$arity = 1); Opal.def(self, '$drop_while', $Enumerable_drop_while$28 = function $$drop_while() { var $iter = $Enumerable_drop_while$28.$$p, block = $iter || nil, self = this; if ($iter) $Enumerable_drop_while$28.$$p = null; if ($iter) $Enumerable_drop_while$28.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("drop_while") }; var result = [], dropping = true; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments); if (dropping) { var value = Opal.yield1(block, param); if ($falsy(value)) { dropping = false; result.push(param); } } else { result.push(param); } }; self.$each(); return result; ; }, $Enumerable_drop_while$28.$$arity = 0); Opal.def(self, '$each_cons', $Enumerable_each_cons$29 = function $$each_cons(n) { var $iter = $Enumerable_each_cons$29.$$p, block = $iter || nil, $$30, self = this; if ($iter) $Enumerable_each_cons$29.$$p = null; if ($iter) $Enumerable_each_cons$29.$$p = null;; if ($truthy(arguments.length != 1)) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arguments.length) + " for 1)")}; n = $$($nesting, 'Opal').$try_convert(n, $$($nesting, 'Integer'), "to_int"); if ($truthy(n <= 0)) { self.$raise($$($nesting, 'ArgumentError'), "invalid size")}; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["each_cons", n], ($$30 = function(){var self = $$30.$$s || this, $a, enum_size = nil; enum_size = self.$enumerator_size(); if ($truthy(enum_size['$nil?']())) { return nil } else if ($truthy(($truthy($a = enum_size['$=='](0)) ? $a : $rb_lt(enum_size, n)))) { return 0 } else { return $rb_plus($rb_minus(enum_size, n), 1) };}, $$30.$$s = self, $$30.$$arity = 0, $$30)) }; var buffer = [], result = nil; self.$each.$$p = function() { var element = $$($nesting, 'Opal').$destructure(arguments); buffer.push(element); if (buffer.length > n) { buffer.shift(); } if (buffer.length == n) { Opal.yield1(block, buffer.slice(0, n)); } } self.$each(); return result; ; }, $Enumerable_each_cons$29.$$arity = 1); Opal.def(self, '$each_entry', $Enumerable_each_entry$31 = function $$each_entry($a) { var $iter = $Enumerable_each_entry$31.$$p, block = $iter || nil, $post_args, data, $$32, self = this; if ($iter) $Enumerable_each_entry$31.$$p = null; if ($iter) $Enumerable_each_entry$31.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); data = $post_args;; if ((block !== nil)) { } else { return $send(self, 'to_enum', ["each_entry"].concat(Opal.to_a(data)), ($$32 = function(){var self = $$32.$$s || this; return self.$enumerator_size()}, $$32.$$s = self, $$32.$$arity = 0, $$32)) }; self.$each.$$p = function() { var item = $$($nesting, 'Opal').$destructure(arguments); Opal.yield1(block, item); } self.$each.apply(self, data); return self; ; }, $Enumerable_each_entry$31.$$arity = -1); Opal.def(self, '$each_slice', $Enumerable_each_slice$33 = function $$each_slice(n) { var $iter = $Enumerable_each_slice$33.$$p, block = $iter || nil, $$34, self = this; if ($iter) $Enumerable_each_slice$33.$$p = null; if ($iter) $Enumerable_each_slice$33.$$p = null;; n = $$($nesting, 'Opal').$coerce_to(n, $$($nesting, 'Integer'), "to_int"); if ($truthy(n <= 0)) { self.$raise($$($nesting, 'ArgumentError'), "invalid slice size")}; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["each_slice", n], ($$34 = function(){var self = $$34.$$s || this; if ($truthy(self['$respond_to?']("size"))) { return $rb_divide(self.$size(), n).$ceil() } else { return nil }}, $$34.$$s = self, $$34.$$arity = 0, $$34)) }; var result, slice = [] self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments); slice.push(param); if (slice.length === n) { Opal.yield1(block, slice); 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) { Opal.yield1(block, slice); } ; return nil; }, $Enumerable_each_slice$33.$$arity = 1); Opal.def(self, '$each_with_index', $Enumerable_each_with_index$35 = function $$each_with_index($a) { var $iter = $Enumerable_each_with_index$35.$$p, block = $iter || nil, $post_args, args, $$36, self = this; if ($iter) $Enumerable_each_with_index$35.$$p = null; if ($iter) $Enumerable_each_with_index$35.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["each_with_index"].concat(Opal.to_a(args)), ($$36 = function(){var self = $$36.$$s || this; return self.$enumerator_size()}, $$36.$$s = self, $$36.$$arity = 0, $$36)) }; var result, index = 0; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments); block(param, index); index++; }; self.$each.apply(self, args); if (result !== undefined) { return result; } ; return self; }, $Enumerable_each_with_index$35.$$arity = -1); Opal.def(self, '$each_with_object', $Enumerable_each_with_object$37 = function $$each_with_object(object) { var $iter = $Enumerable_each_with_object$37.$$p, block = $iter || nil, $$38, self = this; if ($iter) $Enumerable_each_with_object$37.$$p = null; if ($iter) $Enumerable_each_with_object$37.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["each_with_object", object], ($$38 = function(){var self = $$38.$$s || this; return self.$enumerator_size()}, $$38.$$s = self, $$38.$$arity = 0, $$38)) }; var result; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments); block(param, object); }; self.$each(); if (result !== undefined) { return result; } ; return object; }, $Enumerable_each_with_object$37.$$arity = 1); Opal.def(self, '$entries', $Enumerable_entries$39 = function $$entries($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var result = []; self.$each.$$p = function() { result.push($$($nesting, 'Opal').$destructure(arguments)); }; self.$each.apply(self, args); return result; ; }, $Enumerable_entries$39.$$arity = -1); Opal.alias(self, "find", "detect"); Opal.def(self, '$find_all', $Enumerable_find_all$40 = function $$find_all() { var $iter = $Enumerable_find_all$40.$$p, block = $iter || nil, $$41, self = this; if ($iter) $Enumerable_find_all$40.$$p = null; if ($iter) $Enumerable_find_all$40.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["find_all"], ($$41 = function(){var self = $$41.$$s || this; return self.$enumerator_size()}, $$41.$$s = self, $$41.$$arity = 0, $$41)) }; var result = []; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); if ($truthy(value)) { result.push(param); } }; self.$each(); return result; ; }, $Enumerable_find_all$40.$$arity = 0); Opal.def(self, '$find_index', $Enumerable_find_index$42 = function $$find_index(object) {try { var $iter = $Enumerable_find_index$42.$$p, block = $iter || nil, $$43, $$44, self = this, index = nil; if ($iter) $Enumerable_find_index$42.$$p = null; if ($iter) $Enumerable_find_index$42.$$p = null;; ; if ($truthy(object === undefined && block === nil)) { return self.$enum_for("find_index")}; if (object != null && block !== nil) { self.$warn("warning: given block not used") } ; index = 0; if ($truthy(object != null)) { $send(self, 'each', [], ($$43 = function($a){var self = $$43.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($$($nesting, 'Opal').$destructure(value)['$=='](object)) { Opal.ret(index)}; return index += 1;;}, $$43.$$s = self, $$43.$$arity = -1, $$43)) } else { $send(self, 'each', [], ($$44 = function($a){var self = $$44.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy(Opal.yieldX(block, Opal.to_a(value)))) { Opal.ret(index)}; return index += 1;;}, $$44.$$s = self, $$44.$$arity = -1, $$44)) }; return nil; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_find_index$42.$$arity = -1); Opal.def(self, '$first', $Enumerable_first$45 = function $$first(number) {try { var $$46, $$47, self = this, result = nil, current = nil; ; if ($truthy(number === undefined)) { return $send(self, 'each', [], ($$46 = function(value){var self = $$46.$$s || this; if (value == null) { value = nil; }; Opal.ret(value);}, $$46.$$s = self, $$46.$$arity = 1, $$46)) } else { result = []; number = $$($nesting, 'Opal').$coerce_to(number, $$($nesting, 'Integer'), "to_int"); if ($truthy(number < 0)) { self.$raise($$($nesting, 'ArgumentError'), "attempt to take negative size")}; if ($truthy(number == 0)) { return []}; current = 0; $send(self, 'each', [], ($$47 = function($a){var self = $$47.$$s || this, $post_args, args; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; result.push($$($nesting, 'Opal').$destructure(args)); if ($truthy(number <= ++current)) { Opal.ret(result) } else { return nil };}, $$47.$$s = self, $$47.$$arity = -1, $$47)); return result; }; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_first$45.$$arity = -1); Opal.alias(self, "flat_map", "collect_concat"); Opal.def(self, '$grep', $Enumerable_grep$48 = function $$grep(pattern) { var $iter = $Enumerable_grep$48.$$p, block = $iter || nil, $$49, self = this, result = nil; if ($iter) $Enumerable_grep$48.$$p = null; if ($iter) $Enumerable_grep$48.$$p = null;; result = []; $send(self, 'each', [], ($$49 = function($a){var self = $$49.$$s || this, $post_args, value, cmp = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; cmp = comparableForPattern(value); if ($truthy($send(pattern, '__send__', ["==="].concat(Opal.to_a(cmp))))) { } else { return nil; }; if ((block !== nil)) { if ($truthy($rb_gt(value.$length(), 1))) { value = [value]}; value = Opal.yieldX(block, Opal.to_a(value)); } else if ($truthy($rb_le(value.$length(), 1))) { value = value['$[]'](0)}; return result.$push(value);}, $$49.$$s = self, $$49.$$arity = -1, $$49)); return result; }, $Enumerable_grep$48.$$arity = 1); Opal.def(self, '$grep_v', $Enumerable_grep_v$50 = function $$grep_v(pattern) { var $iter = $Enumerable_grep_v$50.$$p, block = $iter || nil, $$51, self = this, result = nil; if ($iter) $Enumerable_grep_v$50.$$p = null; if ($iter) $Enumerable_grep_v$50.$$p = null;; result = []; $send(self, 'each', [], ($$51 = function($a){var self = $$51.$$s || this, $post_args, value, cmp = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; cmp = comparableForPattern(value); if ($truthy($send(pattern, '__send__', ["==="].concat(Opal.to_a(cmp))))) { return nil;}; if ((block !== nil)) { if ($truthy($rb_gt(value.$length(), 1))) { value = [value]}; value = Opal.yieldX(block, Opal.to_a(value)); } else if ($truthy($rb_le(value.$length(), 1))) { value = value['$[]'](0)}; return result.$push(value);}, $$51.$$s = self, $$51.$$arity = -1, $$51)); return result; }, $Enumerable_grep_v$50.$$arity = 1); Opal.def(self, '$group_by', $Enumerable_group_by$52 = function $$group_by() { var $iter = $Enumerable_group_by$52.$$p, block = $iter || nil, $$53, $a, self = this, hash = nil, $writer = nil; if ($iter) $Enumerable_group_by$52.$$p = null; if ($iter) $Enumerable_group_by$52.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["group_by"], ($$53 = function(){var self = $$53.$$s || this; return self.$enumerator_size()}, $$53.$$s = self, $$53.$$arity = 0, $$53)) }; hash = $hash2([], {}); var result; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); ($truthy($a = hash['$[]'](value)) ? $a : (($writer = [value, []]), $send(hash, '[]=', Opal.to_a($writer)), $writer[$rb_minus($writer["length"], 1)]))['$<<'](param); } self.$each(); if (result !== undefined) { return result; } ; return hash; }, $Enumerable_group_by$52.$$arity = 0); Opal.def(self, '$include?', $Enumerable_include$ques$54 = function(obj) {try { var $$55, self = this; $send(self, 'each', [], ($$55 = function($a){var self = $$55.$$s || this, $post_args, args; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($$($nesting, 'Opal').$destructure(args)['$=='](obj)) { Opal.ret(true) } else { return nil };}, $$55.$$s = self, $$55.$$arity = -1, $$55)); return false; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_include$ques$54.$$arity = 1); Opal.def(self, '$inject', $Enumerable_inject$56 = function $$inject(object, sym) { var $iter = $Enumerable_inject$56.$$p, block = $iter || nil, self = this; if ($iter) $Enumerable_inject$56.$$p = null; if ($iter) $Enumerable_inject$56.$$p = null;; ; ; var result = object; if (block !== nil && sym === undefined) { self.$each.$$p = function() { var value = $$($nesting, 'Opal').$destructure(arguments); if (result === undefined) { result = value; return; } value = Opal.yieldX(block, [result, value]); result = value; }; } else { if (sym === undefined) { if (!$$($nesting, 'Symbol')['$==='](object)) { self.$raise($$($nesting, 'TypeError'), "" + (object.$inspect()) + " is not a Symbol"); } sym = object; result = undefined; } self.$each.$$p = function() { var value = $$($nesting, 'Opal').$destructure(arguments); if (result === undefined) { result = value; return; } result = (result).$__send__(sym, value); }; } self.$each(); return result == undefined ? nil : result; ; }, $Enumerable_inject$56.$$arity = -1); Opal.def(self, '$lazy', $Enumerable_lazy$57 = function $$lazy() { var $$58, self = this; return $send($$$($$($nesting, 'Enumerator'), 'Lazy'), 'new', [self, self.$enumerator_size()], ($$58 = function(enum$, $a){var self = $$58.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; return $send(enum$, 'yield', Opal.to_a(args));}, $$58.$$s = self, $$58.$$arity = -2, $$58)) }, $Enumerable_lazy$57.$$arity = 0); Opal.def(self, '$enumerator_size', $Enumerable_enumerator_size$59 = function $$enumerator_size() { var self = this; if ($truthy(self['$respond_to?']("size"))) { return self.$size() } else { return nil } }, $Enumerable_enumerator_size$59.$$arity = 0); Opal.alias(self, "map", "collect"); Opal.def(self, '$max', $Enumerable_max$60 = function $$max(n) { var $iter = $Enumerable_max$60.$$p, block = $iter || nil, self = this; if ($iter) $Enumerable_max$60.$$p = null; if ($iter) $Enumerable_max$60.$$p = null;; ; if (n === undefined || n === nil) { var result, value; self.$each.$$p = function() { var item = $$($nesting, 'Opal').$destructure(arguments); if (result === undefined) { result = item; return; } if (block !== nil) { value = Opal.yieldX(block, [item, result]); } else { value = (item)['$<=>'](result); } if (value === nil) { self.$raise($$($nesting, 'ArgumentError'), "comparison failed"); } if (value > 0) { result = item; } } self.$each(); if (result === undefined) { return nil; } else { return result; } } ; n = $$($nesting, 'Opal').$coerce_to(n, $$($nesting, 'Integer'), "to_int"); return $send(self, 'sort', [], block.$to_proc()).$reverse().$first(n); }, $Enumerable_max$60.$$arity = -1); Opal.def(self, '$max_by', $Enumerable_max_by$61 = function $$max_by() { var $iter = $Enumerable_max_by$61.$$p, block = $iter || nil, $$62, self = this; if ($iter) $Enumerable_max_by$61.$$p = null; if ($iter) $Enumerable_max_by$61.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["max_by"], ($$62 = function(){var self = $$62.$$s || this; return self.$enumerator_size()}, $$62.$$s = self, $$62.$$arity = 0, $$62)) }; var result, by; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); if (result === undefined) { result = param; by = value; return; } if ((value)['$<=>'](by) > 0) { result = param by = value; } }; self.$each(); return result === undefined ? nil : result; ; }, $Enumerable_max_by$61.$$arity = 0); Opal.alias(self, "member?", "include?"); Opal.def(self, '$min', $Enumerable_min$63 = function $$min() { var $iter = $Enumerable_min$63.$$p, block = $iter || nil, self = this; if ($iter) $Enumerable_min$63.$$p = null; if ($iter) $Enumerable_min$63.$$p = null;; var result; if (block !== nil) { self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments); if (result === undefined) { result = param; return; } var value = block(param, result); if (value === nil) { self.$raise($$($nesting, 'ArgumentError'), "comparison failed"); } if (value < 0) { result = param; } }; } else { self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments); if (result === undefined) { result = param; return; } if ($$($nesting, 'Opal').$compare(param, result) < 0) { result = param; } }; } self.$each(); return result === undefined ? nil : result; ; }, $Enumerable_min$63.$$arity = 0); Opal.def(self, '$min_by', $Enumerable_min_by$64 = function $$min_by() { var $iter = $Enumerable_min_by$64.$$p, block = $iter || nil, $$65, self = this; if ($iter) $Enumerable_min_by$64.$$p = null; if ($iter) $Enumerable_min_by$64.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["min_by"], ($$65 = function(){var self = $$65.$$s || this; return self.$enumerator_size()}, $$65.$$s = self, $$65.$$arity = 0, $$65)) }; var result, by; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); if (result === undefined) { result = param; by = value; return; } if ((value)['$<=>'](by) < 0) { result = param by = value; } }; self.$each(); return result === undefined ? nil : result; ; }, $Enumerable_min_by$64.$$arity = 0); Opal.def(self, '$minmax', $Enumerable_minmax$66 = function $$minmax() { var $iter = $Enumerable_minmax$66.$$p, block = $iter || nil, $a, $$67, self = this; if ($iter) $Enumerable_minmax$66.$$p = null; if ($iter) $Enumerable_minmax$66.$$p = null;; block = ($truthy($a = block) ? $a : $send(self, 'proc', [], ($$67 = function(a, b){var self = $$67.$$s || this; if (a == null) { a = nil; }; if (b == null) { b = nil; }; return a['$<=>'](b);}, $$67.$$s = self, $$67.$$arity = 2, $$67))); var min = nil, max = nil, first_time = true; self.$each.$$p = function() { var element = $$($nesting, 'Opal').$destructure(arguments); if (first_time) { min = max = element; first_time = false; } else { var min_cmp = block.$call(min, element); if (min_cmp === nil) { self.$raise($$($nesting, 'ArgumentError'), "comparison failed") } else if (min_cmp > 0) { min = element; } var max_cmp = block.$call(max, element); if (max_cmp === nil) { self.$raise($$($nesting, 'ArgumentError'), "comparison failed") } else if (max_cmp < 0) { max = element; } } } self.$each(); return [min, max]; ; }, $Enumerable_minmax$66.$$arity = 0); Opal.def(self, '$minmax_by', $Enumerable_minmax_by$68 = function $$minmax_by() { var $iter = $Enumerable_minmax_by$68.$$p, block = $iter || nil, self = this; if ($iter) $Enumerable_minmax_by$68.$$p = null; if ($iter) $Enumerable_minmax_by$68.$$p = null;; return self.$raise($$($nesting, 'NotImplementedError')); }, $Enumerable_minmax_by$68.$$arity = 0); Opal.def(self, '$none?', $Enumerable_none$ques$69 = function(pattern) {try { var $iter = $Enumerable_none$ques$69.$$p, block = $iter || nil, $$70, $$71, $$72, self = this; if ($iter) $Enumerable_none$ques$69.$$p = null; if ($iter) $Enumerable_none$ques$69.$$p = null;; ; if ($truthy(pattern !== undefined)) { $send(self, 'each', [], ($$70 = function($a){var self = $$70.$$s || this, $post_args, value, comparable = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; comparable = comparableForPattern(value); if ($truthy($send(pattern, 'public_send', ["==="].concat(Opal.to_a(comparable))))) { Opal.ret(false) } else { return nil };}, $$70.$$s = self, $$70.$$arity = -1, $$70)) } else if ((block !== nil)) { $send(self, 'each', [], ($$71 = function($a){var self = $$71.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy(Opal.yieldX(block, Opal.to_a(value)))) { Opal.ret(false) } else { return nil };}, $$71.$$s = self, $$71.$$arity = -1, $$71)) } else { $send(self, 'each', [], ($$72 = function($a){var self = $$72.$$s || this, $post_args, value, item = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; item = $$($nesting, 'Opal').$destructure(value); if ($truthy(item)) { Opal.ret(false) } else { return nil };}, $$72.$$s = self, $$72.$$arity = -1, $$72)) }; return true; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_none$ques$69.$$arity = -1); Opal.def(self, '$one?', $Enumerable_one$ques$73 = function(pattern) {try { var $iter = $Enumerable_one$ques$73.$$p, block = $iter || nil, $$74, $$75, $$76, self = this, count = nil; if ($iter) $Enumerable_one$ques$73.$$p = null; if ($iter) $Enumerable_one$ques$73.$$p = null;; ; count = 0; if ($truthy(pattern !== undefined)) { $send(self, 'each', [], ($$74 = function($a){var self = $$74.$$s || this, $post_args, value, comparable = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; comparable = comparableForPattern(value); if ($truthy($send(pattern, 'public_send', ["==="].concat(Opal.to_a(comparable))))) { count = $rb_plus(count, 1); if ($truthy($rb_gt(count, 1))) { Opal.ret(false) } else { return nil }; } else { return nil };}, $$74.$$s = self, $$74.$$arity = -1, $$74)) } else if ((block !== nil)) { $send(self, 'each', [], ($$75 = function($a){var self = $$75.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy(Opal.yieldX(block, Opal.to_a(value)))) { } else { return nil; }; count = $rb_plus(count, 1); if ($truthy($rb_gt(count, 1))) { Opal.ret(false) } else { return nil };}, $$75.$$s = self, $$75.$$arity = -1, $$75)) } else { $send(self, 'each', [], ($$76 = function($a){var self = $$76.$$s || this, $post_args, value; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; if ($truthy($$($nesting, 'Opal').$destructure(value))) { } else { return nil; }; count = $rb_plus(count, 1); if ($truthy($rb_gt(count, 1))) { Opal.ret(false) } else { return nil };}, $$76.$$s = self, $$76.$$arity = -1, $$76)) }; return count['$=='](1); } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_one$ques$73.$$arity = -1); Opal.def(self, '$partition', $Enumerable_partition$77 = function $$partition() { var $iter = $Enumerable_partition$77.$$p, block = $iter || nil, $$78, self = this; if ($iter) $Enumerable_partition$77.$$p = null; if ($iter) $Enumerable_partition$77.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["partition"], ($$78 = function(){var self = $$78.$$s || this; return self.$enumerator_size()}, $$78.$$s = self, $$78.$$arity = 0, $$78)) }; var truthy = [], falsy = [], result; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); if ($truthy(value)) { truthy.push(param); } else { falsy.push(param); } }; self.$each(); return [truthy, falsy]; ; }, $Enumerable_partition$77.$$arity = 0); Opal.alias(self, "reduce", "inject"); Opal.def(self, '$reject', $Enumerable_reject$79 = function $$reject() { var $iter = $Enumerable_reject$79.$$p, block = $iter || nil, $$80, self = this; if ($iter) $Enumerable_reject$79.$$p = null; if ($iter) $Enumerable_reject$79.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["reject"], ($$80 = function(){var self = $$80.$$s || this; return self.$enumerator_size()}, $$80.$$s = self, $$80.$$arity = 0, $$80)) }; var result = []; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); if ($falsy(value)) { result.push(param); } }; self.$each(); return result; ; }, $Enumerable_reject$79.$$arity = 0); Opal.def(self, '$reverse_each', $Enumerable_reverse_each$81 = function $$reverse_each() { var $iter = $Enumerable_reverse_each$81.$$p, block = $iter || nil, $$82, self = this; if ($iter) $Enumerable_reverse_each$81.$$p = null; if ($iter) $Enumerable_reverse_each$81.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["reverse_each"], ($$82 = function(){var self = $$82.$$s || this; return self.$enumerator_size()}, $$82.$$s = self, $$82.$$arity = 0, $$82)) }; 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; ; }, $Enumerable_reverse_each$81.$$arity = 0); Opal.alias(self, "select", "find_all"); Opal.def(self, '$slice_before', $Enumerable_slice_before$83 = function $$slice_before(pattern) { var $iter = $Enumerable_slice_before$83.$$p, block = $iter || nil, $$84, self = this; if ($iter) $Enumerable_slice_before$83.$$p = null; if ($iter) $Enumerable_slice_before$83.$$p = null;; ; if ($truthy(pattern === undefined && block === nil)) { self.$raise($$($nesting, 'ArgumentError'), "both pattern and block are given")}; if ($truthy(pattern !== undefined && block !== nil || arguments.length > 1)) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arguments.length) + " expected 1)")}; return $send($$($nesting, 'Enumerator'), 'new', [], ($$84 = function(e){var self = $$84.$$s || this; if (e == null) { e = nil; }; var slice = []; if (block !== nil) { if (pattern === undefined) { self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = Opal.yield1(block, param); if ($truthy(value) && slice.length > 0) { e['$<<'](slice); slice = []; } slice.push(param); }; } else { self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = block(param, pattern.$dup()); if ($truthy(value) && slice.length > 0) { e['$<<'](slice); slice = []; } slice.push(param); }; } } else { self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = pattern['$==='](param); if ($truthy(value) && slice.length > 0) { e['$<<'](slice); slice = []; } slice.push(param); }; } self.$each(); if (slice.length > 0) { e['$<<'](slice); } ;}, $$84.$$s = self, $$84.$$arity = 1, $$84)); }, $Enumerable_slice_before$83.$$arity = -1); Opal.def(self, '$slice_after', $Enumerable_slice_after$85 = function $$slice_after(pattern) { var $iter = $Enumerable_slice_after$85.$$p, block = $iter || nil, $$86, $$87, self = this; if ($iter) $Enumerable_slice_after$85.$$p = null; if ($iter) $Enumerable_slice_after$85.$$p = null;; ; if ($truthy(pattern === undefined && block === nil)) { self.$raise($$($nesting, 'ArgumentError'), "both pattern and block are given")}; if ($truthy(pattern !== undefined && block !== nil || arguments.length > 1)) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arguments.length) + " expected 1)")}; if ($truthy(pattern !== undefined)) { block = $send(self, 'proc', [], ($$86 = function(e){var self = $$86.$$s || this; if (e == null) { e = nil; }; return pattern['$==='](e);}, $$86.$$s = self, $$86.$$arity = 1, $$86))}; return $send($$($nesting, 'Enumerator'), 'new', [], ($$87 = function(yielder){var self = $$87.$$s || this; if (yielder == null) { yielder = nil; }; var accumulate; self.$each.$$p = function() { var element = $$($nesting, 'Opal').$destructure(arguments), end_chunk = Opal.yield1(block, element); if (accumulate == null) { accumulate = []; } if ($truthy(end_chunk)) { accumulate.push(element); yielder.$yield(accumulate); accumulate = null; } else { accumulate.push(element) } } self.$each(); if (accumulate != null) { yielder.$yield(accumulate); } ;}, $$87.$$s = self, $$87.$$arity = 1, $$87)); }, $Enumerable_slice_after$85.$$arity = -1); Opal.def(self, '$slice_when', $Enumerable_slice_when$88 = function $$slice_when() { var $iter = $Enumerable_slice_when$88.$$p, block = $iter || nil, $$89, self = this; if ($iter) $Enumerable_slice_when$88.$$p = null; if ($iter) $Enumerable_slice_when$88.$$p = null;; if ((block !== nil)) { } else { self.$raise($$($nesting, 'ArgumentError'), "wrong number of arguments (0 for 1)") }; return $send($$($nesting, 'Enumerator'), 'new', [], ($$89 = function(yielder){var self = $$89.$$s || this; if (yielder == null) { yielder = nil; }; var slice = nil, last_after = nil; self.$each_cons.$$p = function() { var params = $$($nesting, 'Opal').$destructure(arguments), before = params[0], after = params[1], match = Opal.yieldX(block, [before, after]); last_after = after; if (slice === nil) { slice = []; } if ($truthy(match)) { slice.push(before); yielder.$yield(slice); slice = []; } else { slice.push(before); } } self.$each_cons(2); if (slice !== nil) { slice.push(last_after); yielder.$yield(slice); } ;}, $$89.$$s = self, $$89.$$arity = 1, $$89)); }, $Enumerable_slice_when$88.$$arity = 0); Opal.def(self, '$sort', $Enumerable_sort$90 = function $$sort() { var $iter = $Enumerable_sort$90.$$p, block = $iter || nil, $$91, self = this, ary = nil; if ($iter) $Enumerable_sort$90.$$p = null; if ($iter) $Enumerable_sort$90.$$p = null;; ary = self.$to_a(); if ((block !== nil)) { } else { block = $lambda(($$91 = function(a, b){var self = $$91.$$s || this; if (a == null) { a = nil; }; if (b == null) { b = nil; }; return a['$<=>'](b);}, $$91.$$s = self, $$91.$$arity = 2, $$91)) }; return $send(ary, 'sort', [], block.$to_proc()); }, $Enumerable_sort$90.$$arity = 0); Opal.def(self, '$sort_by', $Enumerable_sort_by$92 = function $$sort_by() { var $iter = $Enumerable_sort_by$92.$$p, block = $iter || nil, $$93, $$94, $$95, $$96, self = this, dup = nil; if ($iter) $Enumerable_sort_by$92.$$p = null; if ($iter) $Enumerable_sort_by$92.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["sort_by"], ($$93 = function(){var self = $$93.$$s || this; return self.$enumerator_size()}, $$93.$$s = self, $$93.$$arity = 0, $$93)) }; dup = $send(self, 'map', [], ($$94 = function(){var self = $$94.$$s || this, arg = nil; arg = $$($nesting, 'Opal').$destructure(arguments); return [Opal.yield1(block, arg), arg];}, $$94.$$s = self, $$94.$$arity = 0, $$94)); $send(dup, 'sort!', [], ($$95 = function(a, b){var self = $$95.$$s || this; if (a == null) { a = nil; }; if (b == null) { b = nil; }; return (a[0])['$<=>'](b[0]);}, $$95.$$s = self, $$95.$$arity = 2, $$95)); return $send(dup, 'map!', [], ($$96 = function(i){var self = $$96.$$s || this; if (i == null) { i = nil; }; return i[1];;}, $$96.$$s = self, $$96.$$arity = 1, $$96)); }, $Enumerable_sort_by$92.$$arity = 0); Opal.def(self, '$sum', $Enumerable_sum$97 = function $$sum(initial) { var $$98, $iter = $Enumerable_sum$97.$$p, $yield = $iter || nil, self = this, result = nil; if ($iter) $Enumerable_sum$97.$$p = null; if (initial == null) { initial = 0; }; result = initial; $send(self, 'each', [], ($$98 = function($a){var self = $$98.$$s || this, $post_args, args, item = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; item = (function() {if (($yield !== nil)) { return Opal.yieldX($yield, Opal.to_a(args)); } else { return $$($nesting, 'Opal').$destructure(args) }; return nil; })(); return (result = $rb_plus(result, item));}, $$98.$$s = self, $$98.$$arity = -1, $$98)); return result; }, $Enumerable_sum$97.$$arity = -1); Opal.def(self, '$take', $Enumerable_take$99 = function $$take(num) { var self = this; return self.$first(num) }, $Enumerable_take$99.$$arity = 1); Opal.def(self, '$take_while', $Enumerable_take_while$100 = function $$take_while() {try { var $iter = $Enumerable_take_while$100.$$p, block = $iter || nil, $$101, self = this, result = nil; if ($iter) $Enumerable_take_while$100.$$p = null; if ($iter) $Enumerable_take_while$100.$$p = null;; if ($truthy(block)) { } else { return self.$enum_for("take_while") }; result = []; return $send(self, 'each', [], ($$101 = function($a){var self = $$101.$$s || this, $post_args, args, value = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; value = $$($nesting, 'Opal').$destructure(args); if ($truthy(Opal.yield1(block, value))) { } else { Opal.ret(result) }; return result.push(value);;}, $$101.$$s = self, $$101.$$arity = -1, $$101)); } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Enumerable_take_while$100.$$arity = 0); Opal.def(self, '$uniq', $Enumerable_uniq$102 = function $$uniq() { var $iter = $Enumerable_uniq$102.$$p, block = $iter || nil, $$103, self = this, hash = nil; if ($iter) $Enumerable_uniq$102.$$p = null; if ($iter) $Enumerable_uniq$102.$$p = null;; hash = $hash2([], {}); $send(self, 'each', [], ($$103 = function($a){var self = $$103.$$s || this, $post_args, args, value = nil, produced = nil, $writer = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; value = $$($nesting, 'Opal').$destructure(args); produced = (function() {if ((block !== nil)) { return Opal.yield1(block, value); } else { return value }; return nil; })(); if ($truthy(hash['$key?'](produced))) { return nil } else { $writer = [produced, value]; $send(hash, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; };}, $$103.$$s = self, $$103.$$arity = -1, $$103)); return hash.$values(); }, $Enumerable_uniq$102.$$arity = 0); Opal.alias(self, "to_a", "entries"); Opal.def(self, '$zip', $Enumerable_zip$104 = function $$zip($a) { var $iter = $Enumerable_zip$104.$$p, block = $iter || nil, $post_args, others, self = this; if ($iter) $Enumerable_zip$104.$$p = null; if ($iter) $Enumerable_zip$104.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); others = $post_args;; return $send(self.$to_a(), 'zip', Opal.to_a(others)); }, $Enumerable_zip$104.$$arity = -1); })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/enumerator"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $falsy = Opal.falsy; Opal.add_stubs(['$require', '$include', '$allocate', '$new', '$to_proc', '$coerce_to', '$nil?', '$empty?', '$+', '$class', '$__send__', '$===', '$call', '$enum_for', '$size', '$destructure', '$inspect', '$any?', '$[]', '$raise', '$yield', '$each', '$enumerator_size', '$respond_to?', '$try_convert', '$<', '$for']); self.$require("corelib/enumerable"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Enumerator'); var $nesting = [self].concat($parent_nesting), $Enumerator_for$1, $Enumerator_initialize$2, $Enumerator_each$3, $Enumerator_size$4, $Enumerator_with_index$5, $Enumerator_inspect$7; self.$$prototype.size = self.$$prototype.args = self.$$prototype.object = self.$$prototype.method = nil; self.$include($$($nesting, 'Enumerable')); self.$$prototype.$$is_enumerator = true; Opal.defs(self, '$for', $Enumerator_for$1 = function(object, $a, $b) { var $iter = $Enumerator_for$1.$$p, block = $iter || nil, $post_args, method, args, self = this; if ($iter) $Enumerator_for$1.$$p = null; if ($iter) $Enumerator_for$1.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); if ($post_args.length > 0) { method = $post_args[0]; $post_args.splice(0, 1); } if (method == null) { method = "each"; }; args = $post_args;; var obj = self.$allocate(); obj.object = object; obj.size = block; obj.method = method; obj.args = args; return obj; ; }, $Enumerator_for$1.$$arity = -2); Opal.def(self, '$initialize', $Enumerator_initialize$2 = function $$initialize($a) { var $iter = $Enumerator_initialize$2.$$p, block = $iter || nil, $post_args, self = this; if ($iter) $Enumerator_initialize$2.$$p = null; if ($iter) $Enumerator_initialize$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; if ($truthy(block)) { self.object = $send($$($nesting, 'Generator'), 'new', [], block.$to_proc()); self.method = "each"; self.args = []; self.size = arguments[0] || nil; if ($truthy(self.size)) { return (self.size = $$($nesting, 'Opal').$coerce_to(self.size, $$($nesting, '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); }; }, $Enumerator_initialize$2.$$arity = -1); Opal.def(self, '$each', $Enumerator_each$3 = function $$each($a) { var $iter = $Enumerator_each$3.$$p, block = $iter || nil, $post_args, args, $b, self = this; if ($iter) $Enumerator_each$3.$$p = null; if ($iter) $Enumerator_each$3.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(($truthy($b = block['$nil?']()) ? args['$empty?']() : $b))) { return self}; args = $rb_plus(self.args, args); if ($truthy(block['$nil?']())) { return $send(self.$class(), 'new', [self.object, self.method].concat(Opal.to_a(args)))}; return $send(self.object, '__send__', [self.method].concat(Opal.to_a(args)), block.$to_proc()); }, $Enumerator_each$3.$$arity = -1); Opal.def(self, '$size', $Enumerator_size$4 = function $$size() { var self = this; if ($truthy($$($nesting, 'Proc')['$==='](self.size))) { return $send(self.size, 'call', Opal.to_a(self.args)) } else { return self.size } }, $Enumerator_size$4.$$arity = 0); Opal.def(self, '$with_index', $Enumerator_with_index$5 = function $$with_index(offset) { var $iter = $Enumerator_with_index$5.$$p, block = $iter || nil, $$6, self = this; if ($iter) $Enumerator_with_index$5.$$p = null; if ($iter) $Enumerator_with_index$5.$$p = null;; if (offset == null) { offset = 0; }; offset = (function() {if ($truthy(offset)) { return $$($nesting, 'Opal').$coerce_to(offset, $$($nesting, 'Integer'), "to_int") } else { return 0 }; return nil; })(); if ($truthy(block)) { } else { return $send(self, 'enum_for', ["with_index", offset], ($$6 = function(){var self = $$6.$$s || this; return self.$size()}, $$6.$$s = self, $$6.$$arity = 0, $$6)) }; var result, index = offset; self.$each.$$p = function() { var param = $$($nesting, 'Opal').$destructure(arguments), value = block(param, index); index++; return value; } return self.$each(); ; }, $Enumerator_with_index$5.$$arity = -1); Opal.alias(self, "with_object", "each_with_object"); Opal.def(self, '$inspect', $Enumerator_inspect$7 = function $$inspect() { var self = this, result = nil; result = "" + "#<" + (self.$class()) + ": " + (self.object.$inspect()) + ":" + (self.method); if ($truthy(self.args['$any?']())) { result = $rb_plus(result, "" + "(" + (self.args.$inspect()['$[]']($$($nesting, 'Range').$new(1, -2))) + ")")}; return $rb_plus(result, ">"); }, $Enumerator_inspect$7.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Generator'); var $nesting = [self].concat($parent_nesting), $Generator_initialize$8, $Generator_each$9; self.$$prototype.block = nil; self.$include($$($nesting, 'Enumerable')); Opal.def(self, '$initialize', $Generator_initialize$8 = function $$initialize() { var $iter = $Generator_initialize$8.$$p, block = $iter || nil, self = this; if ($iter) $Generator_initialize$8.$$p = null; if ($iter) $Generator_initialize$8.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'LocalJumpError'), "no block given") }; return (self.block = block); }, $Generator_initialize$8.$$arity = 0); return (Opal.def(self, '$each', $Generator_each$9 = function $$each($a) { var $iter = $Generator_each$9.$$p, block = $iter || nil, $post_args, args, self = this, yielder = nil; if ($iter) $Generator_each$9.$$p = null; if ($iter) $Generator_each$9.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; yielder = $send($$($nesting, 'Yielder'), 'new', [], block.$to_proc()); try { args.unshift(yielder); Opal.yieldX(self.block, args); } catch (e) { if (e === $breaker) { return $breaker.$v; } else { throw e; } } ; return self; }, $Generator_each$9.$$arity = -1), nil) && 'each'; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Yielder'); var $nesting = [self].concat($parent_nesting), $Yielder_initialize$10, $Yielder_yield$11, $Yielder_$lt$lt$12; self.$$prototype.block = nil; Opal.def(self, '$initialize', $Yielder_initialize$10 = function $$initialize() { var $iter = $Yielder_initialize$10.$$p, block = $iter || nil, self = this; if ($iter) $Yielder_initialize$10.$$p = null; if ($iter) $Yielder_initialize$10.$$p = null;; return (self.block = block); }, $Yielder_initialize$10.$$arity = 0); Opal.def(self, '$yield', $Yielder_yield$11 = function($a) { var $post_args, values, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); values = $post_args;; var value = Opal.yieldX(self.block, values); if (value === $breaker) { throw $breaker; } return value; ; }, $Yielder_yield$11.$$arity = -1); return (Opal.def(self, '$<<', $Yielder_$lt$lt$12 = function($a) { var $post_args, values, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); values = $post_args;; $send(self, 'yield', Opal.to_a(values)); return self; }, $Yielder_$lt$lt$12.$$arity = -1), nil) && '<<'; })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Lazy'); var $nesting = [self].concat($parent_nesting), $Lazy_initialize$13, $Lazy_lazy$16, $Lazy_collect$17, $Lazy_collect_concat$19, $Lazy_drop$23, $Lazy_drop_while$25, $Lazy_enum_for$27, $Lazy_find_all$28, $Lazy_grep$30, $Lazy_reject$33, $Lazy_take$35, $Lazy_take_while$37, $Lazy_inspect$39; self.$$prototype.enumerator = nil; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'StopLazyError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Exception'), $nesting); Opal.def(self, '$initialize', $Lazy_initialize$13 = function $$initialize(object, size) { var $iter = $Lazy_initialize$13.$$p, block = $iter || nil, $$14, self = this; if ($iter) $Lazy_initialize$13.$$p = null; if ($iter) $Lazy_initialize$13.$$p = null;; if (size == null) { size = nil; }; if ((block !== nil)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to call lazy new without a block") }; self.enumerator = object; return $send(self, Opal.find_super_dispatcher(self, 'initialize', $Lazy_initialize$13, false), [size], ($$14 = function(yielder, $a){var self = $$14.$$s || this, $post_args, each_args, $$15; if (yielder == null) { yielder = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); each_args = $post_args;; try { return $send(object, 'each', Opal.to_a(each_args), ($$15 = function($b){var self = $$15.$$s || this, $post_args, args; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; args.unshift(yielder); Opal.yieldX(block, args); ;}, $$15.$$s = self, $$15.$$arity = -1, $$15)) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'Exception')])) { try { return nil } finally { Opal.pop_exception() } } else { throw $err; } };}, $$14.$$s = self, $$14.$$arity = -2, $$14)); }, $Lazy_initialize$13.$$arity = -2); Opal.alias(self, "force", "to_a"); Opal.def(self, '$lazy', $Lazy_lazy$16 = function $$lazy() { var self = this; return self }, $Lazy_lazy$16.$$arity = 0); Opal.def(self, '$collect', $Lazy_collect$17 = function $$collect() { var $iter = $Lazy_collect$17.$$p, block = $iter || nil, $$18, self = this; if ($iter) $Lazy_collect$17.$$p = null; if ($iter) $Lazy_collect$17.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to call lazy map without a block") }; return $send($$($nesting, 'Lazy'), 'new', [self, self.$enumerator_size()], ($$18 = function(enum$, $a){var self = $$18.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; var value = Opal.yieldX(block, args); enum$.$yield(value); ;}, $$18.$$s = self, $$18.$$arity = -2, $$18)); }, $Lazy_collect$17.$$arity = 0); Opal.def(self, '$collect_concat', $Lazy_collect_concat$19 = function $$collect_concat() { var $iter = $Lazy_collect_concat$19.$$p, block = $iter || nil, $$20, self = this; if ($iter) $Lazy_collect_concat$19.$$p = null; if ($iter) $Lazy_collect_concat$19.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to call lazy map without a block") }; return $send($$($nesting, 'Lazy'), 'new', [self, nil], ($$20 = function(enum$, $a){var self = $$20.$$s || this, $post_args, args, $$21, $$22; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; var value = Opal.yieldX(block, args); if ((value)['$respond_to?']("force") && (value)['$respond_to?']("each")) { $send((value), 'each', [], ($$21 = function(v){var self = $$21.$$s || this; if (v == null) { v = nil; }; return enum$.$yield(v);}, $$21.$$s = self, $$21.$$arity = 1, $$21)) } else { var array = $$($nesting, 'Opal').$try_convert(value, $$($nesting, 'Array'), "to_ary"); if (array === nil) { enum$.$yield(value); } else { $send((value), 'each', [], ($$22 = function(v){var self = $$22.$$s || this; if (v == null) { v = nil; }; return enum$.$yield(v);}, $$22.$$s = self, $$22.$$arity = 1, $$22)); } } ;}, $$20.$$s = self, $$20.$$arity = -2, $$20)); }, $Lazy_collect_concat$19.$$arity = 0); Opal.def(self, '$drop', $Lazy_drop$23 = function $$drop(n) { var $$24, self = this, current_size = nil, set_size = nil, dropped = nil; n = $$($nesting, 'Opal').$coerce_to(n, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_lt(n, 0))) { self.$raise($$($nesting, 'ArgumentError'), "attempt to drop negative size")}; current_size = self.$enumerator_size(); set_size = (function() {if ($truthy($$($nesting, 'Integer')['$==='](current_size))) { if ($truthy($rb_lt(n, current_size))) { return n } else { return current_size } } else { return current_size }; return nil; })(); dropped = 0; return $send($$($nesting, 'Lazy'), 'new', [self, set_size], ($$24 = function(enum$, $a){var self = $$24.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy($rb_lt(dropped, n))) { return (dropped = $rb_plus(dropped, 1)) } else { return $send(enum$, 'yield', Opal.to_a(args)) };}, $$24.$$s = self, $$24.$$arity = -2, $$24)); }, $Lazy_drop$23.$$arity = 1); Opal.def(self, '$drop_while', $Lazy_drop_while$25 = function $$drop_while() { var $iter = $Lazy_drop_while$25.$$p, block = $iter || nil, $$26, self = this, succeeding = nil; if ($iter) $Lazy_drop_while$25.$$p = null; if ($iter) $Lazy_drop_while$25.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to call lazy drop_while without a block") }; succeeding = true; return $send($$($nesting, 'Lazy'), 'new', [self, nil], ($$26 = function(enum$, $a){var self = $$26.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(succeeding)) { var value = Opal.yieldX(block, args); if ($falsy(value)) { succeeding = false; $send(enum$, 'yield', Opal.to_a(args)); } } else { return $send(enum$, 'yield', Opal.to_a(args)) };}, $$26.$$s = self, $$26.$$arity = -2, $$26)); }, $Lazy_drop_while$25.$$arity = 0); Opal.def(self, '$enum_for', $Lazy_enum_for$27 = function $$enum_for($a, $b) { var $iter = $Lazy_enum_for$27.$$p, block = $iter || nil, $post_args, method, args, self = this; if ($iter) $Lazy_enum_for$27.$$p = null; if ($iter) $Lazy_enum_for$27.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); if ($post_args.length > 0) { method = $post_args[0]; $post_args.splice(0, 1); } if (method == null) { method = "each"; }; args = $post_args;; return $send(self.$class(), 'for', [self, method].concat(Opal.to_a(args)), block.$to_proc()); }, $Lazy_enum_for$27.$$arity = -1); Opal.def(self, '$find_all', $Lazy_find_all$28 = function $$find_all() { var $iter = $Lazy_find_all$28.$$p, block = $iter || nil, $$29, self = this; if ($iter) $Lazy_find_all$28.$$p = null; if ($iter) $Lazy_find_all$28.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to call lazy select without a block") }; return $send($$($nesting, 'Lazy'), 'new', [self, nil], ($$29 = function(enum$, $a){var self = $$29.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; var value = Opal.yieldX(block, args); if ($truthy(value)) { $send(enum$, 'yield', Opal.to_a(args)); } ;}, $$29.$$s = self, $$29.$$arity = -2, $$29)); }, $Lazy_find_all$28.$$arity = 0); Opal.alias(self, "flat_map", "collect_concat"); Opal.def(self, '$grep', $Lazy_grep$30 = function $$grep(pattern) { var $iter = $Lazy_grep$30.$$p, block = $iter || nil, $$31, $$32, self = this; if ($iter) $Lazy_grep$30.$$p = null; if ($iter) $Lazy_grep$30.$$p = null;; if ($truthy(block)) { return $send($$($nesting, 'Lazy'), 'new', [self, nil], ($$31 = function(enum$, $a){var self = $$31.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; var param = $$($nesting, 'Opal').$destructure(args), value = pattern['$==='](param); if ($truthy(value)) { value = Opal.yield1(block, param); enum$.$yield(Opal.yield1(block, param)); } ;}, $$31.$$s = self, $$31.$$arity = -2, $$31)) } else { return $send($$($nesting, 'Lazy'), 'new', [self, nil], ($$32 = function(enum$, $a){var self = $$32.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; var param = $$($nesting, 'Opal').$destructure(args), value = pattern['$==='](param); if ($truthy(value)) { enum$.$yield(param); } ;}, $$32.$$s = self, $$32.$$arity = -2, $$32)) }; }, $Lazy_grep$30.$$arity = 1); Opal.alias(self, "map", "collect"); Opal.alias(self, "select", "find_all"); Opal.def(self, '$reject', $Lazy_reject$33 = function $$reject() { var $iter = $Lazy_reject$33.$$p, block = $iter || nil, $$34, self = this; if ($iter) $Lazy_reject$33.$$p = null; if ($iter) $Lazy_reject$33.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to call lazy reject without a block") }; return $send($$($nesting, 'Lazy'), 'new', [self, nil], ($$34 = function(enum$, $a){var self = $$34.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; var value = Opal.yieldX(block, args); if ($falsy(value)) { $send(enum$, 'yield', Opal.to_a(args)); } ;}, $$34.$$s = self, $$34.$$arity = -2, $$34)); }, $Lazy_reject$33.$$arity = 0); Opal.def(self, '$take', $Lazy_take$35 = function $$take(n) { var $$36, self = this, current_size = nil, set_size = nil, taken = nil; n = $$($nesting, 'Opal').$coerce_to(n, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_lt(n, 0))) { self.$raise($$($nesting, 'ArgumentError'), "attempt to take negative size")}; current_size = self.$enumerator_size(); set_size = (function() {if ($truthy($$($nesting, 'Integer')['$==='](current_size))) { if ($truthy($rb_lt(n, current_size))) { return n } else { return current_size } } else { return current_size }; return nil; })(); taken = 0; return $send($$($nesting, 'Lazy'), 'new', [self, set_size], ($$36 = function(enum$, $a){var self = $$36.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy($rb_lt(taken, n))) { $send(enum$, 'yield', Opal.to_a(args)); return (taken = $rb_plus(taken, 1)); } else { return self.$raise($$($nesting, 'StopLazyError')) };}, $$36.$$s = self, $$36.$$arity = -2, $$36)); }, $Lazy_take$35.$$arity = 1); Opal.def(self, '$take_while', $Lazy_take_while$37 = function $$take_while() { var $iter = $Lazy_take_while$37.$$p, block = $iter || nil, $$38, self = this; if ($iter) $Lazy_take_while$37.$$p = null; if ($iter) $Lazy_take_while$37.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to call lazy take_while without a block") }; return $send($$($nesting, 'Lazy'), 'new', [self, nil], ($$38 = function(enum$, $a){var self = $$38.$$s || this, $post_args, args; if (enum$ == null) { enum$ = nil; }; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; var value = Opal.yieldX(block, args); if ($truthy(value)) { $send(enum$, 'yield', Opal.to_a(args)); } else { self.$raise($$($nesting, 'StopLazyError')); } ;}, $$38.$$s = self, $$38.$$arity = -2, $$38)); }, $Lazy_take_while$37.$$arity = 0); Opal.alias(self, "to_enum", "enum_for"); return (Opal.def(self, '$inspect', $Lazy_inspect$39 = function $$inspect() { var self = this; return "" + "#<" + (self.$class()) + ": " + (self.enumerator.$inspect()) + ">" }, $Lazy_inspect$39.$$arity = 0), nil) && 'inspect'; })($nesting[0], self, $nesting); })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/numeric"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2; Opal.add_stubs(['$require', '$include', '$instance_of?', '$class', '$Float', '$respond_to?', '$coerce', '$__send__', '$===', '$raise', '$equal?', '$-', '$*', '$div', '$<', '$-@', '$ceil', '$to_f', '$denominator', '$to_r', '$==', '$floor', '$/', '$%', '$Complex', '$zero?', '$numerator', '$abs', '$arg', '$coerce_to!', '$round', '$to_i', '$truncate', '$>']); self.$require("corelib/comparable"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Numeric'); var $nesting = [self].concat($parent_nesting), $Numeric_coerce$1, $Numeric___coerced__$2, $Numeric_$lt_eq_gt$3, $Numeric_$plus$$4, $Numeric_$minus$$5, $Numeric_$percent$6, $Numeric_abs$7, $Numeric_abs2$8, $Numeric_angle$9, $Numeric_ceil$10, $Numeric_conj$11, $Numeric_denominator$12, $Numeric_div$13, $Numeric_divmod$14, $Numeric_fdiv$15, $Numeric_floor$16, $Numeric_i$17, $Numeric_imag$18, $Numeric_integer$ques$19, $Numeric_nonzero$ques$20, $Numeric_numerator$21, $Numeric_polar$22, $Numeric_quo$23, $Numeric_real$24, $Numeric_real$ques$25, $Numeric_rect$26, $Numeric_round$27, $Numeric_to_c$28, $Numeric_to_int$29, $Numeric_truncate$30, $Numeric_zero$ques$31, $Numeric_positive$ques$32, $Numeric_negative$ques$33, $Numeric_dup$34, $Numeric_clone$35, $Numeric_finite$ques$36, $Numeric_infinite$ques$37; self.$include($$($nesting, 'Comparable')); Opal.def(self, '$coerce', $Numeric_coerce$1 = function $$coerce(other) { var self = this; if ($truthy(other['$instance_of?'](self.$class()))) { return [other, self]}; return [self.$Float(other), self.$Float(self)]; }, $Numeric_coerce$1.$$arity = 1); Opal.def(self, '$__coerced__', $Numeric___coerced__$2 = function $$__coerced__(method, other) { var $a, $b, self = this, a = nil, b = nil, $case = nil; if ($truthy(other['$respond_to?']("coerce"))) { $b = other.$coerce(self), $a = Opal.to_ary($b), (a = ($a[0] == null ? nil : $a[0])), (b = ($a[1] == null ? nil : $a[1])), $b; return a.$__send__(method, b); } else { return (function() {$case = method; if ("+"['$===']($case) || "-"['$===']($case) || "*"['$===']($case) || "/"['$===']($case) || "%"['$===']($case) || "&"['$===']($case) || "|"['$===']($case) || "^"['$===']($case) || "**"['$===']($case)) {return self.$raise($$($nesting, 'TypeError'), "" + (other.$class()) + " can't be coerced into Numeric")} else if (">"['$===']($case) || ">="['$===']($case) || "<"['$===']($case) || "<="['$===']($case) || "<=>"['$===']($case)) {return self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + (self.$class()) + " with " + (other.$class()) + " failed")} else { return nil }})() } }, $Numeric___coerced__$2.$$arity = 2); Opal.def(self, '$<=>', $Numeric_$lt_eq_gt$3 = function(other) { var self = this; if ($truthy(self['$equal?'](other))) { return 0}; return nil; }, $Numeric_$lt_eq_gt$3.$$arity = 1); Opal.def(self, '$+@', $Numeric_$plus$$4 = function() { var self = this; return self }, $Numeric_$plus$$4.$$arity = 0); Opal.def(self, '$-@', $Numeric_$minus$$5 = function() { var self = this; return $rb_minus(0, self) }, $Numeric_$minus$$5.$$arity = 0); Opal.def(self, '$%', $Numeric_$percent$6 = function(other) { var self = this; return $rb_minus(self, $rb_times(other, self.$div(other))) }, $Numeric_$percent$6.$$arity = 1); Opal.def(self, '$abs', $Numeric_abs$7 = function $$abs() { var self = this; if ($rb_lt(self, 0)) { return self['$-@']() } else { return self } }, $Numeric_abs$7.$$arity = 0); Opal.def(self, '$abs2', $Numeric_abs2$8 = function $$abs2() { var self = this; return $rb_times(self, self) }, $Numeric_abs2$8.$$arity = 0); Opal.def(self, '$angle', $Numeric_angle$9 = function $$angle() { var self = this; if ($rb_lt(self, 0)) { return $$$($$($nesting, 'Math'), 'PI') } else { return 0 } }, $Numeric_angle$9.$$arity = 0); Opal.alias(self, "arg", "angle"); Opal.def(self, '$ceil', $Numeric_ceil$10 = function $$ceil(ndigits) { var self = this; if (ndigits == null) { ndigits = 0; }; return self.$to_f().$ceil(ndigits); }, $Numeric_ceil$10.$$arity = -1); Opal.def(self, '$conj', $Numeric_conj$11 = function $$conj() { var self = this; return self }, $Numeric_conj$11.$$arity = 0); Opal.alias(self, "conjugate", "conj"); Opal.def(self, '$denominator', $Numeric_denominator$12 = function $$denominator() { var self = this; return self.$to_r().$denominator() }, $Numeric_denominator$12.$$arity = 0); Opal.def(self, '$div', $Numeric_div$13 = function $$div(other) { var self = this; if (other['$=='](0)) { self.$raise($$($nesting, 'ZeroDivisionError'), "divided by o")}; return $rb_divide(self, other).$floor(); }, $Numeric_div$13.$$arity = 1); Opal.def(self, '$divmod', $Numeric_divmod$14 = function $$divmod(other) { var self = this; return [self.$div(other), self['$%'](other)] }, $Numeric_divmod$14.$$arity = 1); Opal.def(self, '$fdiv', $Numeric_fdiv$15 = function $$fdiv(other) { var self = this; return $rb_divide(self.$to_f(), other) }, $Numeric_fdiv$15.$$arity = 1); Opal.def(self, '$floor', $Numeric_floor$16 = function $$floor(ndigits) { var self = this; if (ndigits == null) { ndigits = 0; }; return self.$to_f().$floor(ndigits); }, $Numeric_floor$16.$$arity = -1); Opal.def(self, '$i', $Numeric_i$17 = function $$i() { var self = this; return self.$Complex(0, self) }, $Numeric_i$17.$$arity = 0); Opal.def(self, '$imag', $Numeric_imag$18 = function $$imag() { var self = this; return 0 }, $Numeric_imag$18.$$arity = 0); Opal.alias(self, "imaginary", "imag"); Opal.def(self, '$integer?', $Numeric_integer$ques$19 = function() { var self = this; return false }, $Numeric_integer$ques$19.$$arity = 0); Opal.alias(self, "magnitude", "abs"); Opal.alias(self, "modulo", "%"); Opal.def(self, '$nonzero?', $Numeric_nonzero$ques$20 = function() { var self = this; if ($truthy(self['$zero?']())) { return nil } else { return self } }, $Numeric_nonzero$ques$20.$$arity = 0); Opal.def(self, '$numerator', $Numeric_numerator$21 = function $$numerator() { var self = this; return self.$to_r().$numerator() }, $Numeric_numerator$21.$$arity = 0); Opal.alias(self, "phase", "arg"); Opal.def(self, '$polar', $Numeric_polar$22 = function $$polar() { var self = this; return [self.$abs(), self.$arg()] }, $Numeric_polar$22.$$arity = 0); Opal.def(self, '$quo', $Numeric_quo$23 = function $$quo(other) { var self = this; return $rb_divide($$($nesting, 'Opal')['$coerce_to!'](self, $$($nesting, 'Rational'), "to_r"), other) }, $Numeric_quo$23.$$arity = 1); Opal.def(self, '$real', $Numeric_real$24 = function $$real() { var self = this; return self }, $Numeric_real$24.$$arity = 0); Opal.def(self, '$real?', $Numeric_real$ques$25 = function() { var self = this; return true }, $Numeric_real$ques$25.$$arity = 0); Opal.def(self, '$rect', $Numeric_rect$26 = function $$rect() { var self = this; return [self, 0] }, $Numeric_rect$26.$$arity = 0); Opal.alias(self, "rectangular", "rect"); Opal.def(self, '$round', $Numeric_round$27 = function $$round(digits) { var self = this; ; return self.$to_f().$round(digits); }, $Numeric_round$27.$$arity = -1); Opal.def(self, '$to_c', $Numeric_to_c$28 = function $$to_c() { var self = this; return self.$Complex(self, 0) }, $Numeric_to_c$28.$$arity = 0); Opal.def(self, '$to_int', $Numeric_to_int$29 = function $$to_int() { var self = this; return self.$to_i() }, $Numeric_to_int$29.$$arity = 0); Opal.def(self, '$truncate', $Numeric_truncate$30 = function $$truncate(ndigits) { var self = this; if (ndigits == null) { ndigits = 0; }; return self.$to_f().$truncate(ndigits); }, $Numeric_truncate$30.$$arity = -1); Opal.def(self, '$zero?', $Numeric_zero$ques$31 = function() { var self = this; return self['$=='](0) }, $Numeric_zero$ques$31.$$arity = 0); Opal.def(self, '$positive?', $Numeric_positive$ques$32 = function() { var self = this; return $rb_gt(self, 0) }, $Numeric_positive$ques$32.$$arity = 0); Opal.def(self, '$negative?', $Numeric_negative$ques$33 = function() { var self = this; return $rb_lt(self, 0) }, $Numeric_negative$ques$33.$$arity = 0); Opal.def(self, '$dup', $Numeric_dup$34 = function $$dup() { var self = this; return self }, $Numeric_dup$34.$$arity = 0); Opal.def(self, '$clone', $Numeric_clone$35 = function $$clone($kwargs) { var freeze, self = this; if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; freeze = $kwargs.$$smap["freeze"]; if (freeze == null) { freeze = true }; return self; }, $Numeric_clone$35.$$arity = -1); Opal.def(self, '$finite?', $Numeric_finite$ques$36 = function() { var self = this; return true }, $Numeric_finite$ques$36.$$arity = 0); return (Opal.def(self, '$infinite?', $Numeric_infinite$ques$37 = function() { var self = this; return nil }, $Numeric_infinite$ques$37.$$arity = 0), nil) && 'infinite?'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/array"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_ge(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2, $send = Opal.send, $gvars = Opal.gvars; Opal.add_stubs(['$require', '$include', '$to_a', '$warn', '$raise', '$replace', '$respond_to?', '$to_ary', '$coerce_to', '$coerce_to?', '$===', '$join', '$to_str', '$class', '$hash', '$<=>', '$==', '$object_id', '$inspect', '$enum_for', '$bsearch_index', '$to_proc', '$nil?', '$coerce_to!', '$>', '$*', '$enumerator_size', '$empty?', '$size', '$map', '$equal?', '$dup', '$each', '$[]', '$dig', '$eql?', '$length', '$begin', '$end', '$exclude_end?', '$flatten', '$__id__', '$to_s', '$new', '$max', '$min', '$!', '$>=', '$**', '$delete_if', '$reverse', '$rotate', '$rand', '$at', '$keep_if', '$shuffle!', '$<', '$sort', '$sort_by', '$!=', '$times', '$[]=', '$-', '$<<', '$values', '$is_a?', '$last', '$first', '$upto', '$reject', '$pristine', '$singleton_class']); self.$require("corelib/enumerable"); self.$require("corelib/numeric"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Array'); var $nesting = [self].concat($parent_nesting), $Array_$$$1, $Array_initialize$2, $Array_try_convert$3, $Array_$$4, $Array_$$5, $Array_$$6, $Array_$plus$7, $Array_$minus$8, $Array_$lt$lt$9, $Array_$lt_eq_gt$10, $Array_$eq_eq$11, $Array_$$$12, $Array_$$$eq$13, $Array_any$ques$14, $Array_assoc$15, $Array_at$16, $Array_bsearch_index$17, $Array_bsearch$18, $Array_cycle$19, $Array_clear$21, $Array_count$22, $Array_initialize_copy$23, $Array_collect$24, $Array_collect$excl$26, $Array_combination$28, $Array_repeated_combination$30, $Array_compact$32, $Array_compact$excl$33, $Array_concat$34, $Array_delete$37, $Array_delete_at$38, $Array_delete_if$39, $Array_dig$41, $Array_drop$42, $Array_dup$43, $Array_each$44, $Array_each_index$46, $Array_empty$ques$48, $Array_eql$ques$49, $Array_fetch$50, $Array_fill$51, $Array_first$52, $Array_flatten$53, $Array_flatten$excl$54, $Array_hash$55, $Array_include$ques$56, $Array_index$57, $Array_insert$58, $Array_inspect$59, $Array_join$60, $Array_keep_if$61, $Array_last$63, $Array_length$64, $Array_max$65, $Array_min$66, $Array_permutation$67, $Array_repeated_permutation$69, $Array_pop$71, $Array_product$72, $Array_push$73, $Array_rassoc$74, $Array_reject$75, $Array_reject$excl$77, $Array_replace$79, $Array_reverse$80, $Array_reverse$excl$81, $Array_reverse_each$82, $Array_rindex$84, $Array_rotate$85, $Array_rotate$excl$86, $Array_sample$89, $Array_select$90, $Array_select$excl$92, $Array_shift$94, $Array_shuffle$95, $Array_shuffle$excl$96, $Array_slice$excl$97, $Array_sort$98, $Array_sort$excl$99, $Array_sort_by$excl$100, $Array_take$102, $Array_take_while$103, $Array_to_a$104, $Array_to_h$105, $Array_transpose$106, $Array_uniq$109, $Array_uniq$excl$110, $Array_unshift$111, $Array_values_at$112, $Array_zip$115, $Array_inherited$116, $Array_instance_variables$117, $Array_pack$119; self.$include($$($nesting, 'Enumerable')); Opal.defineProperty(self.$$prototype, '$$is_array', true); function toArraySubclass(obj, klass) { if (klass.$$name === Opal.Array) { return obj; } else { return klass.$allocate().$replace((obj).$to_a()); } } ; Opal.defs(self, '$[]', $Array_$$$1 = function($a) { var $post_args, objects, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); objects = $post_args;; return toArraySubclass(objects, self);; }, $Array_$$$1.$$arity = -1); Opal.def(self, '$initialize', $Array_initialize$2 = function $$initialize(size, obj) { var $iter = $Array_initialize$2.$$p, block = $iter || nil, self = this; if ($iter) $Array_initialize$2.$$p = null; if ($iter) $Array_initialize$2.$$p = null;; if (size == null) { size = nil; }; if (obj == null) { obj = nil; }; if (obj !== nil && block !== nil) { self.$warn("warning: block supersedes default value argument") } if (size > $$$($$($nesting, 'Integer'), 'MAX')) { self.$raise($$($nesting, 'ArgumentError'), "array size too big") } if (arguments.length > 2) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arguments.length) + " for 0..2)") } if (arguments.length === 0) { self.splice(0, self.length); return self; } if (arguments.length === 1) { if (size.$$is_array) { self.$replace(size.$to_a()) return self; } else if (size['$respond_to?']("to_ary")) { self.$replace(size.$to_ary()) return self; } } size = $$($nesting, 'Opal').$coerce_to(size, $$($nesting, 'Integer'), "to_int") if (size < 0) { self.$raise($$($nesting, 'ArgumentError'), "negative array size") } self.splice(0, self.length); var i, value; if (block === nil) { for (i = 0; i < size; i++) { self.push(obj); } } else { for (i = 0, value; i < size; i++) { value = block(i); self[i] = value; } } return self; ; }, $Array_initialize$2.$$arity = -1); Opal.defs(self, '$try_convert', $Array_try_convert$3 = function $$try_convert(obj) { var self = this; return $$($nesting, 'Opal')['$coerce_to?'](obj, $$($nesting, 'Array'), "to_ary") }, $Array_try_convert$3.$$arity = 1); Opal.def(self, '$&', $Array_$$4 = function(other) { var self = this; other = (function() {if ($truthy($$($nesting, 'Array')['$==='](other))) { return other.$to_a() } else { return $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'Array'), "to_ary").$to_a() }; return nil; })(); var result = [], hash = $hash2([], {}), i, length, item; for (i = 0, length = other.length; i < length; i++) { Opal.hash_put(hash, other[i], true); } for (i = 0, length = self.length; i < length; i++) { item = self[i]; if (Opal.hash_delete(hash, item) !== undefined) { result.push(item); } } return result; ; }, $Array_$$4.$$arity = 1); Opal.def(self, '$|', $Array_$$5 = function(other) { var self = this; other = (function() {if ($truthy($$($nesting, 'Array')['$==='](other))) { return other.$to_a() } else { return $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'Array'), "to_ary").$to_a() }; return nil; })(); var hash = $hash2([], {}), i, length, item; for (i = 0, length = self.length; i < length; i++) { Opal.hash_put(hash, self[i], true); } for (i = 0, length = other.length; i < length; i++) { Opal.hash_put(hash, other[i], true); } return hash.$keys(); ; }, $Array_$$5.$$arity = 1); Opal.def(self, '$*', $Array_$$6 = function(other) { var self = this; if ($truthy(other['$respond_to?']("to_str"))) { return self.$join(other.$to_str())}; other = $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'Integer'), "to_int"); if ($truthy(other < 0)) { self.$raise($$($nesting, 'ArgumentError'), "negative argument")}; var result = [], converted = self.$to_a(); for (var i = 0; i < other; i++) { result = result.concat(converted); } return toArraySubclass(result, self.$class()); ; }, $Array_$$6.$$arity = 1); Opal.def(self, '$+', $Array_$plus$7 = function(other) { var self = this; other = (function() {if ($truthy($$($nesting, 'Array')['$==='](other))) { return other.$to_a() } else { return $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'Array'), "to_ary").$to_a() }; return nil; })(); return self.concat(other);; }, $Array_$plus$7.$$arity = 1); Opal.def(self, '$-', $Array_$minus$8 = function(other) { var self = this; other = (function() {if ($truthy($$($nesting, 'Array')['$==='](other))) { return other.$to_a() } else { return $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'Array'), "to_ary").$to_a() }; return nil; })(); if ($truthy(self.length === 0)) { return []}; if ($truthy(other.length === 0)) { return self.slice()}; var result = [], hash = $hash2([], {}), i, length, item; for (i = 0, length = other.length; i < length; i++) { Opal.hash_put(hash, other[i], true); } for (i = 0, length = self.length; i < length; i++) { item = self[i]; if (Opal.hash_get(hash, item) === undefined) { result.push(item); } } return result; ; }, $Array_$minus$8.$$arity = 1); Opal.def(self, '$<<', $Array_$lt$lt$9 = function(object) { var self = this; self.push(object); return self; }, $Array_$lt$lt$9.$$arity = 1); Opal.def(self, '$<=>', $Array_$lt_eq_gt$10 = function(other) { var self = this; if ($truthy($$($nesting, 'Array')['$==='](other))) { other = other.$to_a() } else if ($truthy(other['$respond_to?']("to_ary"))) { other = other.$to_ary().$to_a() } else { return nil }; if (self.$hash() === other.$hash()) { return 0; } var count = Math.min(self.length, other.length); for (var i = 0; i < count; i++) { var tmp = (self[i])['$<=>'](other[i]); if (tmp !== 0) { return tmp; } } return (self.length)['$<=>'](other.length); ; }, $Array_$lt_eq_gt$10.$$arity = 1); Opal.def(self, '$==', $Array_$eq_eq$11 = function(other) { var self = this; var recursed = {}; function _eqeq(array, other) { var i, length, a, b; if (array === other) return true; if (!other.$$is_array) { if ($$($nesting, 'Opal')['$respond_to?'](other, "to_ary")) { return (other)['$=='](array); } else { return false; } } if (array.$$constructor !== Array) array = (array).$to_a(); if (other.$$constructor !== Array) other = (other).$to_a(); if (array.length !== other.length) { return false; } recursed[(array).$object_id()] = true; for (i = 0, length = array.length; i < length; i++) { a = array[i]; b = other[i]; if (a.$$is_array) { if (b.$$is_array && b.length !== a.length) { return false; } if (!recursed.hasOwnProperty((a).$object_id())) { if (!_eqeq(a, b)) { return false; } } } else { if (!(a)['$=='](b)) { return false; } } } return true; } return _eqeq(self, other); }, $Array_$eq_eq$11.$$arity = 1); function $array_slice_range(self, index) { var size = self.length, exclude, from, to, result; exclude = index.excl; from = Opal.Opal.$coerce_to(index.begin, Opal.Integer, 'to_int'); to = Opal.Opal.$coerce_to(index.end, Opal.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; } result = self.slice(from, to); return toArraySubclass(result, self.$class()); } function $array_slice_index_length(self, index, length) { var size = self.length, exclude, from, to, result; index = Opal.Opal.$coerce_to(index, Opal.Integer, 'to_int'); 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 = Opal.Opal.$coerce_to(length, Opal.Integer, 'to_int'); if (length < 0 || index > size || index < 0) { return nil; } result = self.slice(index, index + length); } return toArraySubclass(result, self.$class()); } ; Opal.def(self, '$[]', $Array_$$$12 = function(index, length) { var self = this; ; if (index.$$is_range) { return $array_slice_range(self, index); } else { return $array_slice_index_length(self, index, length); } ; }, $Array_$$$12.$$arity = -2); Opal.def(self, '$[]=', $Array_$$$eq$13 = function(index, value, extra) { var self = this, data = nil, length = nil; ; var i, size = self.length;; if ($truthy($$($nesting, 'Range')['$==='](index))) { data = (function() {if ($truthy($$($nesting, 'Array')['$==='](value))) { return value.$to_a() } else if ($truthy(value['$respond_to?']("to_ary"))) { return value.$to_ary().$to_a() } else { return [value] }; return nil; })(); var exclude = index.excl, from = $$($nesting, 'Opal').$coerce_to(index.begin, $$($nesting, 'Integer'), "to_int"), to = $$($nesting, 'Opal').$coerce_to(index.end, $$($nesting, 'Integer'), "to_int"); if (from < 0) { from += size; if (from < 0) { self.$raise($$($nesting, 'RangeError'), "" + (index.$inspect()) + " out of range"); } } if (to < 0) { to += size; } if (!exclude) { to += 1; } if (from > size) { for (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 ($truthy(extra === undefined)) { length = 1 } else { length = value; value = extra; data = (function() {if ($truthy($$($nesting, 'Array')['$==='](value))) { return value.$to_a() } else if ($truthy(value['$respond_to?']("to_ary"))) { return value.$to_ary().$to_a() } else { return [value] }; return nil; })(); }; var old; index = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, 'Integer'), "to_int"); length = $$($nesting, 'Opal').$coerce_to(length, $$($nesting, 'Integer'), "to_int"); if (index < 0) { old = index; index += size; if (index < 0) { self.$raise($$($nesting, 'IndexError'), "" + "index " + (old) + " too small for array; minimum " + (-self.length)); } } if (length < 0) { self.$raise($$($nesting, 'IndexError'), "" + "negative length (" + (length) + ")") } if (index > size) { for (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; ; }; }, $Array_$$$eq$13.$$arity = -3); Opal.def(self, '$any?', $Array_any$ques$14 = function(pattern) { var $iter = $Array_any$ques$14.$$p, block = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Array_any$ques$14.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($iter) $Array_any$ques$14.$$p = null;; ; if (self.length === 0) return false; return $send(self, Opal.find_super_dispatcher(self, 'any?', $Array_any$ques$14, false), $zuper, $iter); }, $Array_any$ques$14.$$arity = -1); Opal.def(self, '$assoc', $Array_assoc$15 = function $$assoc(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; }, $Array_assoc$15.$$arity = 1); Opal.def(self, '$at', $Array_at$16 = function $$at(index) { var self = this; index = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, 'Integer'), "to_int"); if (index < 0) { index += self.length; } if (index < 0 || index >= self.length) { return nil; } return self[index]; ; }, $Array_at$16.$$arity = 1); Opal.def(self, '$bsearch_index', $Array_bsearch_index$17 = function $$bsearch_index() { var $iter = $Array_bsearch_index$17.$$p, block = $iter || nil, self = this; if ($iter) $Array_bsearch_index$17.$$p = null; if ($iter) $Array_bsearch_index$17.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("bsearch_index") }; var min = 0, max = self.length, mid, val, ret, smaller = false, satisfied = nil; while (min < max) { mid = min + Math.floor((max - min) / 2); val = self[mid]; ret = Opal.yield1(block, val); if (ret === true) { satisfied = mid; smaller = true; } else if (ret === false || ret === nil) { smaller = false; } else if (ret.$$is_number) { if (ret === 0) { return mid; } smaller = (ret < 0); } else { self.$raise($$($nesting, 'TypeError'), "" + "wrong argument type " + ((ret).$class()) + " (must be numeric, true, false or nil)") } if (smaller) { max = mid; } else { min = mid + 1; } } return satisfied; ; }, $Array_bsearch_index$17.$$arity = 0); Opal.def(self, '$bsearch', $Array_bsearch$18 = function $$bsearch() { var $iter = $Array_bsearch$18.$$p, block = $iter || nil, self = this, index = nil; if ($iter) $Array_bsearch$18.$$p = null; if ($iter) $Array_bsearch$18.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("bsearch") }; index = $send(self, 'bsearch_index', [], block.$to_proc()); if (index != null && index.$$is_number) { return self[index]; } else { return index; } ; }, $Array_bsearch$18.$$arity = 0); Opal.def(self, '$cycle', $Array_cycle$19 = function $$cycle(n) { var $iter = $Array_cycle$19.$$p, block = $iter || nil, $$20, $a, self = this; if ($iter) $Array_cycle$19.$$p = null; if ($iter) $Array_cycle$19.$$p = null;; if (n == null) { n = nil; }; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["cycle", n], ($$20 = function(){var self = $$20.$$s || this; if ($truthy(n['$nil?']())) { return $$$($$($nesting, 'Float'), 'INFINITY') } else { n = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_gt(n, 0))) { return $rb_times(self.$enumerator_size(), n) } else { return 0 }; }}, $$20.$$s = self, $$20.$$arity = 0, $$20)) }; if ($truthy(($truthy($a = self['$empty?']()) ? $a : n['$=='](0)))) { return nil}; var i, length, value; if (n === nil) { while (true) { for (i = 0, length = self.length; i < length; i++) { value = Opal.yield1(block, self[i]); } } } else { n = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if (n <= 0) { return self; } while (n > 0) { for (i = 0, length = self.length; i < length; i++) { value = Opal.yield1(block, self[i]); } n--; } } ; return self; }, $Array_cycle$19.$$arity = -1); Opal.def(self, '$clear', $Array_clear$21 = function $$clear() { var self = this; self.splice(0, self.length); return self; }, $Array_clear$21.$$arity = 0); Opal.def(self, '$count', $Array_count$22 = function $$count(object) { var $iter = $Array_count$22.$$p, block = $iter || nil, $a, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Array_count$22.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($iter) $Array_count$22.$$p = null;; if (object == null) { object = nil; }; if ($truthy(($truthy($a = object) ? $a : block))) { return $send(self, Opal.find_super_dispatcher(self, 'count', $Array_count$22, false), $zuper, $iter) } else { return self.$size() }; }, $Array_count$22.$$arity = -1); Opal.def(self, '$initialize_copy', $Array_initialize_copy$23 = function $$initialize_copy(other) { var self = this; return self.$replace(other) }, $Array_initialize_copy$23.$$arity = 1); Opal.def(self, '$collect', $Array_collect$24 = function $$collect() { var $iter = $Array_collect$24.$$p, block = $iter || nil, $$25, self = this; if ($iter) $Array_collect$24.$$p = null; if ($iter) $Array_collect$24.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["collect"], ($$25 = function(){var self = $$25.$$s || this; return self.$size()}, $$25.$$s = self, $$25.$$arity = 0, $$25)) }; var result = []; for (var i = 0, length = self.length; i < length; i++) { var value = Opal.yield1(block, self[i]); result.push(value); } return result; ; }, $Array_collect$24.$$arity = 0); Opal.def(self, '$collect!', $Array_collect$excl$26 = function() { var $iter = $Array_collect$excl$26.$$p, block = $iter || nil, $$27, self = this; if ($iter) $Array_collect$excl$26.$$p = null; if ($iter) $Array_collect$excl$26.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["collect!"], ($$27 = function(){var self = $$27.$$s || this; return self.$size()}, $$27.$$s = self, $$27.$$arity = 0, $$27)) }; for (var i = 0, length = self.length; i < length; i++) { var value = Opal.yield1(block, self[i]); self[i] = value; } ; return self; }, $Array_collect$excl$26.$$arity = 0); function binomial_coefficient(n, k) { if (n === k || k === 0) { return 1; } if (k > 0 && n > k) { return binomial_coefficient(n - 1, k - 1) + binomial_coefficient(n - 1, k); } return 0; } ; Opal.def(self, '$combination', $Array_combination$28 = function $$combination(n) { var $$29, $iter = $Array_combination$28.$$p, $yield = $iter || nil, self = this, num = nil; if ($iter) $Array_combination$28.$$p = null; num = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["combination", num], ($$29 = function(){var self = $$29.$$s || this; return binomial_coefficient(self.length, num)}, $$29.$$s = self, $$29.$$arity = 0, $$29)) }; var i, length, stack, chosen, lev, done, next; if (num === 0) { Opal.yield1($yield, []) } else if (num === 1) { for (i = 0, length = self.length; i < length; i++) { Opal.yield1($yield, [self[i]]) } } else if (num === self.length) { Opal.yield1($yield, self.slice()) } else if (num >= 0 && num < self.length) { stack = []; for (i = 0; i <= num + 1; i++) { stack.push(0); } chosen = []; lev = 0; done = false; stack[0] = -1; while (!done) { chosen[lev] = self[stack[lev+1]]; while (lev < num - 1) { lev++; next = stack[lev+1] = stack[lev] + 1; chosen[lev] = self[next]; } Opal.yield1($yield, chosen.slice()) lev++; do { done = (lev === 0); stack[lev]++; lev--; } while ( stack[lev+1] + num === self.length + lev + 1 ); } } ; return self; }, $Array_combination$28.$$arity = 1); Opal.def(self, '$repeated_combination', $Array_repeated_combination$30 = function $$repeated_combination(n) { var $$31, $iter = $Array_repeated_combination$30.$$p, $yield = $iter || nil, self = this, num = nil; if ($iter) $Array_repeated_combination$30.$$p = null; num = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["repeated_combination", num], ($$31 = function(){var self = $$31.$$s || this; return binomial_coefficient(self.length + num - 1, num);}, $$31.$$s = self, $$31.$$arity = 0, $$31)) }; function iterate(max, from, buffer, self) { if (buffer.length == max) { var copy = buffer.slice(); Opal.yield1($yield, copy) return; } for (var i = from; i < self.length; i++) { buffer.push(self[i]); iterate(max, i, buffer, self); buffer.pop(); } } if (num >= 0) { iterate(num, 0, [], self); } ; return self; }, $Array_repeated_combination$30.$$arity = 1); Opal.def(self, '$compact', $Array_compact$32 = function $$compact() { 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; }, $Array_compact$32.$$arity = 0); Opal.def(self, '$compact!', $Array_compact$excl$33 = 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; }, $Array_compact$excl$33.$$arity = 0); Opal.def(self, '$concat', $Array_concat$34 = function $$concat($a) { var $post_args, others, $$35, $$36, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); others = $post_args;; others = $send(others, 'map', [], ($$35 = function(other){var self = $$35.$$s || this; if (other == null) { other = nil; }; other = (function() {if ($truthy($$($nesting, 'Array')['$==='](other))) { return other.$to_a() } else { return $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'Array'), "to_ary").$to_a() }; return nil; })(); if ($truthy(other['$equal?'](self))) { other = other.$dup()}; return other;}, $$35.$$s = self, $$35.$$arity = 1, $$35)); $send(others, 'each', [], ($$36 = function(other){var self = $$36.$$s || this; if (other == null) { other = nil; }; for (var i = 0, length = other.length; i < length; i++) { self.push(other[i]); } ;}, $$36.$$s = self, $$36.$$arity = 1, $$36)); return self; }, $Array_concat$34.$$arity = -1); Opal.def(self, '$delete', $Array_delete$37 = function(object) { var $iter = $Array_delete$37.$$p, $yield = $iter || nil, self = this; if ($iter) $Array_delete$37.$$p = null; var original = self.length; for (var i = 0, length = original; i < length; i++) { if ((self[i])['$=='](object)) { self.splice(i, 1); length--; i--; } } if (self.length === original) { if (($yield !== nil)) { return Opal.yieldX($yield, []); } return nil; } return object; }, $Array_delete$37.$$arity = 1); Opal.def(self, '$delete_at', $Array_delete_at$38 = function $$delete_at(index) { var self = this; index = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, '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; }, $Array_delete_at$38.$$arity = 1); Opal.def(self, '$delete_if', $Array_delete_if$39 = function $$delete_if() { var $iter = $Array_delete_if$39.$$p, block = $iter || nil, $$40, self = this; if ($iter) $Array_delete_if$39.$$p = null; if ($iter) $Array_delete_if$39.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["delete_if"], ($$40 = function(){var self = $$40.$$s || this; return self.$size()}, $$40.$$s = self, $$40.$$arity = 0, $$40)) }; for (var i = 0, length = self.length, value; i < length; i++) { value = block(self[i]); if (value !== false && value !== nil) { self.splice(i, 1); length--; i--; } } ; return self; }, $Array_delete_if$39.$$arity = 0); Opal.def(self, '$dig', $Array_dig$41 = function $$dig(idx, $a) { var $post_args, idxs, self = this, item = nil; $post_args = Opal.slice.call(arguments, 1, arguments.length); idxs = $post_args;; item = self['$[]'](idx); if (item === nil || idxs.length === 0) { return item; } ; if ($truthy(item['$respond_to?']("dig"))) { } else { self.$raise($$($nesting, 'TypeError'), "" + (item.$class()) + " does not have #dig method") }; return $send(item, 'dig', Opal.to_a(idxs)); }, $Array_dig$41.$$arity = -2); Opal.def(self, '$drop', $Array_drop$42 = function $$drop(number) { var self = this; if (number < 0) { self.$raise($$($nesting, 'ArgumentError')) } return self.slice(number); }, $Array_drop$42.$$arity = 1); Opal.def(self, '$dup', $Array_dup$43 = function $$dup() { var $iter = $Array_dup$43.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Array_dup$43.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if (self.$$class === Opal.Array && self.$$class.$allocate.$$pristine && self.$copy_instance_variables.$$pristine && self.$initialize_dup.$$pristine) { return self.slice(0); } ; return $send(self, Opal.find_super_dispatcher(self, 'dup', $Array_dup$43, false), $zuper, $iter); }, $Array_dup$43.$$arity = 0); Opal.def(self, '$each', $Array_each$44 = function $$each() { var $iter = $Array_each$44.$$p, block = $iter || nil, $$45, self = this; if ($iter) $Array_each$44.$$p = null; if ($iter) $Array_each$44.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["each"], ($$45 = function(){var self = $$45.$$s || this; return self.$size()}, $$45.$$s = self, $$45.$$arity = 0, $$45)) }; for (var i = 0, length = self.length; i < length; i++) { var value = Opal.yield1(block, self[i]); } ; return self; }, $Array_each$44.$$arity = 0); Opal.def(self, '$each_index', $Array_each_index$46 = function $$each_index() { var $iter = $Array_each_index$46.$$p, block = $iter || nil, $$47, self = this; if ($iter) $Array_each_index$46.$$p = null; if ($iter) $Array_each_index$46.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["each_index"], ($$47 = function(){var self = $$47.$$s || this; return self.$size()}, $$47.$$s = self, $$47.$$arity = 0, $$47)) }; for (var i = 0, length = self.length; i < length; i++) { var value = Opal.yield1(block, i); } ; return self; }, $Array_each_index$46.$$arity = 0); Opal.def(self, '$empty?', $Array_empty$ques$48 = function() { var self = this; return self.length === 0; }, $Array_empty$ques$48.$$arity = 0); Opal.def(self, '$eql?', $Array_eql$ques$49 = function(other) { var self = this; var recursed = {}; function _eql(array, other) { var i, length, a, b; if (!other.$$is_array) { return false; } other = other.$to_a(); if (array.length !== other.length) { return false; } recursed[(array).$object_id()] = true; for (i = 0, length = array.length; i < length; i++) { a = array[i]; b = other[i]; if (a.$$is_array) { if (b.$$is_array && b.length !== a.length) { return false; } if (!recursed.hasOwnProperty((a).$object_id())) { if (!_eql(a, b)) { return false; } } } else { if (!(a)['$eql?'](b)) { return false; } } } return true; } return _eql(self, other); }, $Array_eql$ques$49.$$arity = 1); Opal.def(self, '$fetch', $Array_fetch$50 = function $$fetch(index, defaults) { var $iter = $Array_fetch$50.$$p, block = $iter || nil, self = this; if ($iter) $Array_fetch$50.$$p = null; if ($iter) $Array_fetch$50.$$p = null;; ; var original = index; index = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, 'Integer'), "to_int"); if (index < 0) { index += self.length; } if (index >= 0 && index < self.length) { return self[index]; } if (block !== nil && defaults != null) { self.$warn("warning: block supersedes default value argument") } if (block !== nil) { return block(original); } if (defaults != null) { return defaults; } if (self.length === 0) { self.$raise($$($nesting, 'IndexError'), "" + "index " + (original) + " outside of array bounds: 0...0") } else { self.$raise($$($nesting, 'IndexError'), "" + "index " + (original) + " outside of array bounds: -" + (self.length) + "..." + (self.length)); } ; }, $Array_fetch$50.$$arity = -2); Opal.def(self, '$fill', $Array_fill$51 = function $$fill($a) { var $iter = $Array_fill$51.$$p, block = $iter || nil, $post_args, args, $b, $c, self = this, one = nil, two = nil, obj = nil, left = nil, right = nil; if ($iter) $Array_fill$51.$$p = null; if ($iter) $Array_fill$51.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var i, length, value;; if ($truthy(block)) { if ($truthy(args.length > 2)) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (args.$length()) + " for 0..2)")}; $c = args, $b = Opal.to_ary($c), (one = ($b[0] == null ? nil : $b[0])), (two = ($b[1] == null ? nil : $b[1])), $c; } else { if ($truthy(args.length == 0)) { self.$raise($$($nesting, 'ArgumentError'), "wrong number of arguments (0 for 1..3)") } else if ($truthy(args.length > 3)) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (args.$length()) + " for 1..3)")}; $c = args, $b = Opal.to_ary($c), (obj = ($b[0] == null ? nil : $b[0])), (one = ($b[1] == null ? nil : $b[1])), (two = ($b[2] == null ? nil : $b[2])), $c; }; if ($truthy($$($nesting, 'Range')['$==='](one))) { if ($truthy(two)) { self.$raise($$($nesting, 'TypeError'), "length invalid with range")}; left = $$($nesting, 'Opal').$coerce_to(one.$begin(), $$($nesting, 'Integer'), "to_int"); if ($truthy(left < 0)) { left += this.length}; if ($truthy(left < 0)) { self.$raise($$($nesting, 'RangeError'), "" + (one.$inspect()) + " out of range")}; right = $$($nesting, 'Opal').$coerce_to(one.$end(), $$($nesting, 'Integer'), "to_int"); if ($truthy(right < 0)) { right += this.length}; if ($truthy(one['$exclude_end?']())) { } else { right += 1 }; if ($truthy(right <= left)) { return self}; } else if ($truthy(one)) { left = $$($nesting, 'Opal').$coerce_to(one, $$($nesting, 'Integer'), "to_int"); if ($truthy(left < 0)) { left += this.length}; if ($truthy(left < 0)) { left = 0}; if ($truthy(two)) { right = $$($nesting, 'Opal').$coerce_to(two, $$($nesting, 'Integer'), "to_int"); if ($truthy(right == 0)) { return self}; right += left; } else { right = this.length }; } else { left = 0; right = this.length; }; if ($truthy(left > this.length)) { for (i = this.length; i < right; i++) { self[i] = nil; } }; if ($truthy(right > this.length)) { this.length = right}; if ($truthy(block)) { for (length = this.length; left < right; left++) { value = block(left); self[left] = value; } } else { for (length = this.length; left < right; left++) { self[left] = obj; } }; return self; }, $Array_fill$51.$$arity = -1); Opal.def(self, '$first', $Array_first$52 = function $$first(count) { var self = this; ; if (count == null) { return self.length === 0 ? nil : self[0]; } count = $$($nesting, 'Opal').$coerce_to(count, $$($nesting, 'Integer'), "to_int"); if (count < 0) { self.$raise($$($nesting, 'ArgumentError'), "negative array size"); } return self.slice(0, count); ; }, $Array_first$52.$$arity = -1); Opal.def(self, '$flatten', $Array_flatten$53 = function $$flatten(level) { var self = this; ; function _flatten(array, level) { var result = [], i, length, item, ary; array = (array).$to_a(); for (i = 0, length = array.length; i < length; i++) { item = array[i]; if (!$$($nesting, 'Opal')['$respond_to?'](item, "to_ary", true)) { result.push(item); continue; } ary = (item).$to_ary(); if (ary === nil) { result.push(item); continue; } if (!ary.$$is_array) { self.$raise($$($nesting, 'TypeError')); } if (ary === self) { self.$raise($$($nesting, 'ArgumentError')); } switch (level) { case undefined: result = result.concat(_flatten(ary)); break; case 0: result.push(ary); break; default: result.push.apply(result, _flatten(ary, level - 1)); } } return result; } if (level !== undefined) { level = $$($nesting, 'Opal').$coerce_to(level, $$($nesting, 'Integer'), "to_int"); } return toArraySubclass(_flatten(self, level), self.$class()); ; }, $Array_flatten$53.$$arity = -1); Opal.def(self, '$flatten!', $Array_flatten$excl$54 = 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; }, $Array_flatten$excl$54.$$arity = -1); Opal.def(self, '$hash', $Array_hash$55 = function $$hash() { var self = this; var top = (Opal.hash_ids === undefined), result = ['A'], hash_id = self.$object_id(), item, i, key; try { if (top) { Opal.hash_ids = Object.create(null); } // return early for recursive structures if (Opal.hash_ids[hash_id]) { return 'self'; } for (key in Opal.hash_ids) { item = Opal.hash_ids[key]; if (self['$eql?'](item)) { return 'self'; } } Opal.hash_ids[hash_id] = self; for (i = 0; i < self.length; i++) { item = self[i]; result.push(item.$hash()); } return result.join(','); } finally { if (top) { Opal.hash_ids = undefined; } } }, $Array_hash$55.$$arity = 0); Opal.def(self, '$include?', $Array_include$ques$56 = function(member) { var self = this; for (var i = 0, length = self.length; i < length; i++) { if ((self[i])['$=='](member)) { return true; } } return false; }, $Array_include$ques$56.$$arity = 1); Opal.def(self, '$index', $Array_index$57 = function $$index(object) { var $iter = $Array_index$57.$$p, block = $iter || nil, self = this; if ($iter) $Array_index$57.$$p = null; if ($iter) $Array_index$57.$$p = null;; ; var i, length, value; if (object != null && block !== nil) { self.$warn("warning: given block not used") } if (object != null) { for (i = 0, length = self.length; i < length; i++) { if ((self[i])['$=='](object)) { return i; } } } else if (block !== nil) { for (i = 0, length = self.length; i < length; i++) { value = block(self[i]); if (value !== false && value !== nil) { return i; } } } else { return self.$enum_for("index"); } return nil; ; }, $Array_index$57.$$arity = -1); Opal.def(self, '$insert', $Array_insert$58 = function $$insert(index, $a) { var $post_args, objects, self = this; $post_args = Opal.slice.call(arguments, 1, arguments.length); objects = $post_args;; index = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, 'Integer'), "to_int"); if (objects.length > 0) { if (index < 0) { index += self.length + 1; if (index < 0) { self.$raise($$($nesting, '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; }, $Array_insert$58.$$arity = -2); Opal.def(self, '$inspect', $Array_inspect$59 = function $$inspect() { 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(', ') + ']'; }, $Array_inspect$59.$$arity = 0); Opal.def(self, '$join', $Array_join$60 = function $$join(sep) { var self = this; if ($gvars[","] == null) $gvars[","] = nil; if (sep == null) { sep = nil; }; if ($truthy(self.length === 0)) { return ""}; if ($truthy(sep === nil)) { sep = $gvars[","]}; var result = []; var i, length, item, tmp; for (i = 0, length = self.length; i < length; i++) { item = self[i]; if ($$($nesting, 'Opal')['$respond_to?'](item, "to_str")) { tmp = (item).$to_str(); if (tmp !== nil) { result.push((tmp).$to_s()); continue; } } if ($$($nesting, 'Opal')['$respond_to?'](item, "to_ary")) { tmp = (item).$to_ary(); if (tmp === self) { self.$raise($$($nesting, 'ArgumentError')); } if (tmp !== nil) { result.push((tmp).$join(sep)); continue; } } if ($$($nesting, 'Opal')['$respond_to?'](item, "to_s")) { tmp = (item).$to_s(); if (tmp !== nil) { result.push(tmp); continue; } } self.$raise($$($nesting, 'NoMethodError').$new("" + (Opal.inspect(item)) + " doesn't respond to #to_str, #to_ary or #to_s", "to_str")); } if (sep === nil) { return result.join(''); } else { return result.join($$($nesting, 'Opal')['$coerce_to!'](sep, $$($nesting, 'String'), "to_str").$to_s()); } ; }, $Array_join$60.$$arity = -1); Opal.def(self, '$keep_if', $Array_keep_if$61 = function $$keep_if() { var $iter = $Array_keep_if$61.$$p, block = $iter || nil, $$62, self = this; if ($iter) $Array_keep_if$61.$$p = null; if ($iter) $Array_keep_if$61.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["keep_if"], ($$62 = function(){var self = $$62.$$s || this; return self.$size()}, $$62.$$s = self, $$62.$$arity = 0, $$62)) }; for (var i = 0, length = self.length, value; i < length; i++) { value = block(self[i]); if (value === false || value === nil) { self.splice(i, 1); length--; i--; } } ; return self; }, $Array_keep_if$61.$$arity = 0); Opal.def(self, '$last', $Array_last$63 = function $$last(count) { var self = this; ; if (count == null) { return self.length === 0 ? nil : self[self.length - 1]; } count = $$($nesting, 'Opal').$coerce_to(count, $$($nesting, 'Integer'), "to_int"); if (count < 0) { self.$raise($$($nesting, 'ArgumentError'), "negative array size"); } if (count > self.length) { count = self.length; } return self.slice(self.length - count, self.length); ; }, $Array_last$63.$$arity = -1); Opal.def(self, '$length', $Array_length$64 = function $$length() { var self = this; return self.length; }, $Array_length$64.$$arity = 0); Opal.alias(self, "map", "collect"); Opal.alias(self, "map!", "collect!"); Opal.def(self, '$max', $Array_max$65 = function $$max(n) { var $iter = $Array_max$65.$$p, block = $iter || nil, self = this; if ($iter) $Array_max$65.$$p = null; if ($iter) $Array_max$65.$$p = null;; ; return $send(self.$each(), 'max', [n], block.$to_proc()); }, $Array_max$65.$$arity = -1); Opal.def(self, '$min', $Array_min$66 = function $$min() { var $iter = $Array_min$66.$$p, block = $iter || nil, self = this; if ($iter) $Array_min$66.$$p = null; if ($iter) $Array_min$66.$$p = null;; return $send(self.$each(), 'min', [], block.$to_proc()); }, $Array_min$66.$$arity = 0); // Returns the product of from, from-1, ..., from - how_many + 1. function descending_factorial(from, how_many) { var count = how_many >= 0 ? 1 : 0; while (how_many) { count *= from; from--; how_many--; } return count; } ; Opal.def(self, '$permutation', $Array_permutation$67 = function $$permutation(num) { var $iter = $Array_permutation$67.$$p, block = $iter || nil, $$68, self = this, perm = nil, used = nil; if ($iter) $Array_permutation$67.$$p = null; if ($iter) $Array_permutation$67.$$p = null;; ; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["permutation", num], ($$68 = function(){var self = $$68.$$s || this; return descending_factorial(self.length, num === undefined ? self.length : num);}, $$68.$$s = self, $$68.$$arity = 0, $$68)) }; var permute, offensive, output; if (num === undefined) { num = self.length; } else { num = $$($nesting, 'Opal').$coerce_to(num, $$($nesting, 'Integer'), "to_int") } if (num < 0 || self.length < num) { // no permutations, yield nothing } else if (num === 0) { // exactly one permutation: the zero-length array Opal.yield1(block, []) } else if (num === 1) { // this is a special, easy case for (var i = 0; i < self.length; i++) { Opal.yield1(block, [self[i]]) } } else { // this is the general case (perm = $$($nesting, 'Array').$new(num)); (used = $$($nesting, 'Array').$new(self.length, false)); permute = function(num, perm, index, used, blk) { self = this; for(var i = 0; i < self.length; i++){ if(used['$[]'](i)['$!']()) { perm[index] = i; if(index < num - 1) { used[i] = true; permute.call(self, num, perm, index + 1, used, blk); used[i] = false; } else { output = []; for (var j = 0; j < perm.length; j++) { output.push(self[perm[j]]); } Opal.yield1(blk, output); } } } } if ((block !== nil)) { // offensive (both definitions) copy. offensive = self.slice(); permute.call(offensive, num, perm, 0, used, block); } else { permute.call(self, num, perm, 0, used, block); } } ; return self; }, $Array_permutation$67.$$arity = -1); Opal.def(self, '$repeated_permutation', $Array_repeated_permutation$69 = function $$repeated_permutation(n) { var $$70, $iter = $Array_repeated_permutation$69.$$p, $yield = $iter || nil, self = this, num = nil; if ($iter) $Array_repeated_permutation$69.$$p = null; num = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["repeated_permutation", num], ($$70 = function(){var self = $$70.$$s || this; if ($truthy($rb_ge(num, 0))) { return self.$size()['$**'](num) } else { return 0 }}, $$70.$$s = self, $$70.$$arity = 0, $$70)) }; function iterate(max, buffer, self) { if (buffer.length == max) { var copy = buffer.slice(); Opal.yield1($yield, copy) return; } for (var i = 0; i < self.length; i++) { buffer.push(self[i]); iterate(max, buffer, self); buffer.pop(); } } iterate(num, [], self.slice()); ; return self; }, $Array_repeated_permutation$69.$$arity = 1); Opal.def(self, '$pop', $Array_pop$71 = function $$pop(count) { var self = this; ; if ($truthy(count === undefined)) { if ($truthy(self.length === 0)) { return nil}; return self.pop();}; count = $$($nesting, 'Opal').$coerce_to(count, $$($nesting, 'Integer'), "to_int"); if ($truthy(count < 0)) { self.$raise($$($nesting, 'ArgumentError'), "negative array size")}; if ($truthy(self.length === 0)) { return []}; if ($truthy(count > self.length)) { return self.splice(0, self.length); } else { return self.splice(self.length - count, self.length); }; }, $Array_pop$71.$$arity = -1); Opal.def(self, '$product', $Array_product$72 = function $$product($a) { var $iter = $Array_product$72.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Array_product$72.$$p = null; if ($iter) $Array_product$72.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var result = (block !== nil) ? null : [], n = args.length + 1, counters = new Array(n), lengths = new Array(n), arrays = new Array(n), i, m, subarray, len, resultlen = 1; arrays[0] = self; for (i = 1; i < n; i++) { arrays[i] = $$($nesting, 'Opal').$coerce_to(args[i - 1], $$($nesting, 'Array'), "to_ary"); } for (i = 0; i < n; i++) { len = arrays[i].length; if (len === 0) { return result || self; } resultlen *= len; if (resultlen > 2147483647) { self.$raise($$($nesting, 'RangeError'), "too big to product") } lengths[i] = len; counters[i] = 0; } outer_loop: for (;;) { subarray = []; for (i = 0; i < n; i++) { subarray.push(arrays[i][counters[i]]); } if (result) { result.push(subarray); } else { Opal.yield1(block, subarray) } m = n - 1; counters[m]++; while (counters[m] === lengths[m]) { counters[m] = 0; if (--m < 0) break outer_loop; counters[m]++; } } return result || self; ; }, $Array_product$72.$$arity = -1); Opal.def(self, '$push', $Array_push$73 = function $$push($a) { var $post_args, objects, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); objects = $post_args;; for (var i = 0, length = objects.length; i < length; i++) { self.push(objects[i]); } ; return self; }, $Array_push$73.$$arity = -1); Opal.alias(self, "append", "push"); Opal.def(self, '$rassoc', $Array_rassoc$74 = function $$rassoc(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; }, $Array_rassoc$74.$$arity = 1); Opal.def(self, '$reject', $Array_reject$75 = function $$reject() { var $iter = $Array_reject$75.$$p, block = $iter || nil, $$76, self = this; if ($iter) $Array_reject$75.$$p = null; if ($iter) $Array_reject$75.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["reject"], ($$76 = function(){var self = $$76.$$s || this; return self.$size()}, $$76.$$s = self, $$76.$$arity = 0, $$76)) }; var result = []; for (var i = 0, length = self.length, value; i < length; i++) { value = block(self[i]); if (value === false || value === nil) { result.push(self[i]); } } return result; ; }, $Array_reject$75.$$arity = 0); Opal.def(self, '$reject!', $Array_reject$excl$77 = function() { var $iter = $Array_reject$excl$77.$$p, block = $iter || nil, $$78, self = this, original = nil; if ($iter) $Array_reject$excl$77.$$p = null; if ($iter) $Array_reject$excl$77.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["reject!"], ($$78 = function(){var self = $$78.$$s || this; return self.$size()}, $$78.$$s = self, $$78.$$arity = 0, $$78)) }; original = self.$length(); $send(self, 'delete_if', [], block.$to_proc()); if (self.$length()['$=='](original)) { return nil } else { return self }; }, $Array_reject$excl$77.$$arity = 0); Opal.def(self, '$replace', $Array_replace$79 = function $$replace(other) { var self = this; other = (function() {if ($truthy($$($nesting, 'Array')['$==='](other))) { return other.$to_a() } else { return $$($nesting, 'Opal').$coerce_to(other, $$($nesting, 'Array'), "to_ary").$to_a() }; return nil; })(); self.splice(0, self.length); self.push.apply(self, other); ; return self; }, $Array_replace$79.$$arity = 1); Opal.def(self, '$reverse', $Array_reverse$80 = function $$reverse() { var self = this; return self.slice(0).reverse(); }, $Array_reverse$80.$$arity = 0); Opal.def(self, '$reverse!', $Array_reverse$excl$81 = function() { var self = this; return self.reverse(); }, $Array_reverse$excl$81.$$arity = 0); Opal.def(self, '$reverse_each', $Array_reverse_each$82 = function $$reverse_each() { var $iter = $Array_reverse_each$82.$$p, block = $iter || nil, $$83, self = this; if ($iter) $Array_reverse_each$82.$$p = null; if ($iter) $Array_reverse_each$82.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["reverse_each"], ($$83 = function(){var self = $$83.$$s || this; return self.$size()}, $$83.$$s = self, $$83.$$arity = 0, $$83)) }; $send(self.$reverse(), 'each', [], block.$to_proc()); return self; }, $Array_reverse_each$82.$$arity = 0); Opal.def(self, '$rindex', $Array_rindex$84 = function $$rindex(object) { var $iter = $Array_rindex$84.$$p, block = $iter || nil, self = this; if ($iter) $Array_rindex$84.$$p = null; if ($iter) $Array_rindex$84.$$p = null;; ; var i, value; if (object != null && block !== nil) { self.$warn("warning: given block not used") } if (object != null) { for (i = self.length - 1; i >= 0; i--) { if (i >= self.length) { break; } if ((self[i])['$=='](object)) { return i; } } } else if (block !== nil) { for (i = self.length - 1; i >= 0; i--) { if (i >= self.length) { break; } value = block(self[i]); if (value !== false && value !== nil) { return i; } } } else if (object == null) { return self.$enum_for("rindex"); } return nil; ; }, $Array_rindex$84.$$arity = -1); Opal.def(self, '$rotate', $Array_rotate$85 = function $$rotate(n) { var self = this; if (n == null) { n = 1; }; n = $$($nesting, 'Opal').$coerce_to(n, $$($nesting, 'Integer'), "to_int"); var ary, idx, firstPart, lastPart; if (self.length === 1) { return self.slice(); } if (self.length === 0) { return []; } ary = self.slice(); idx = n % ary.length; firstPart = ary.slice(idx); lastPart = ary.slice(0, idx); return firstPart.concat(lastPart); ; }, $Array_rotate$85.$$arity = -1); Opal.def(self, '$rotate!', $Array_rotate$excl$86 = function(cnt) { var self = this, ary = nil; if (cnt == null) { cnt = 1; }; if (self.length === 0 || self.length === 1) { return self; } ; cnt = $$($nesting, 'Opal').$coerce_to(cnt, $$($nesting, 'Integer'), "to_int"); ary = self.$rotate(cnt); return self.$replace(ary); }, $Array_rotate$excl$86.$$arity = -1); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'SampleRandom'); var $nesting = [self].concat($parent_nesting), $SampleRandom_initialize$87, $SampleRandom_rand$88; self.$$prototype.rng = nil; Opal.def(self, '$initialize', $SampleRandom_initialize$87 = function $$initialize(rng) { var self = this; return (self.rng = rng) }, $SampleRandom_initialize$87.$$arity = 1); return (Opal.def(self, '$rand', $SampleRandom_rand$88 = function $$rand(size) { var self = this, random = nil; random = $$($nesting, 'Opal').$coerce_to(self.rng.$rand(size), $$($nesting, 'Integer'), "to_int"); if ($truthy(random < 0)) { self.$raise($$($nesting, 'RangeError'), "random value must be >= 0")}; if ($truthy(random < size)) { } else { self.$raise($$($nesting, 'RangeError'), "random value must be less than Array size") }; return random; }, $SampleRandom_rand$88.$$arity = 1), nil) && 'rand'; })($nesting[0], null, $nesting); Opal.def(self, '$sample', $Array_sample$89 = function $$sample(count, options) { var $a, self = this, o = nil, rng = nil; ; ; if ($truthy(count === undefined)) { return self.$at($$($nesting, 'Kernel').$rand(self.length))}; if ($truthy(options === undefined)) { if ($truthy((o = $$($nesting, 'Opal')['$coerce_to?'](count, $$($nesting, 'Hash'), "to_hash")))) { options = o; count = nil; } else { options = nil; count = $$($nesting, 'Opal').$coerce_to(count, $$($nesting, 'Integer'), "to_int"); } } else { count = $$($nesting, 'Opal').$coerce_to(count, $$($nesting, 'Integer'), "to_int"); options = $$($nesting, 'Opal').$coerce_to(options, $$($nesting, 'Hash'), "to_hash"); }; if ($truthy(($truthy($a = count) ? count < 0 : $a))) { self.$raise($$($nesting, 'ArgumentError'), "count must be greater than 0")}; if ($truthy(options)) { rng = options['$[]']("random")}; rng = (function() {if ($truthy(($truthy($a = rng) ? rng['$respond_to?']("rand") : $a))) { return $$($nesting, 'SampleRandom').$new(rng) } else { return $$($nesting, 'Kernel') }; return nil; })(); if ($truthy(count)) { } else { return self[rng.$rand(self.length)] }; var abandon, spin, result, i, j, k, targetIndex, oldValue; if (count > self.length) { count = self.length; } switch (count) { case 0: return []; break; case 1: return [self[rng.$rand(self.length)]]; break; case 2: i = rng.$rand(self.length); j = rng.$rand(self.length); if (i === j) { j = i === 0 ? i + 1 : i - 1; } return [self[i], self[j]]; break; default: if (self.length / count > 3) { abandon = false; spin = 0; result = $$($nesting, 'Array').$new(count); i = 1; result[0] = rng.$rand(self.length); while (i < count) { k = rng.$rand(self.length); j = 0; while (j < i) { while (k === result[j]) { spin++; if (spin > 100) { abandon = true; break; } k = rng.$rand(self.length); } if (abandon) { break; } j++; } if (abandon) { break; } result[i] = k; i++; } if (!abandon) { i = 0; while (i < count) { result[i] = self[result[i]]; i++; } return result; } } result = self.slice(); for (var c = 0; c < count; c++) { targetIndex = rng.$rand(self.length); oldValue = result[c]; result[c] = result[targetIndex]; result[targetIndex] = oldValue; } return count === self.length ? result : (result)['$[]'](0, count); } ; }, $Array_sample$89.$$arity = -1); Opal.def(self, '$select', $Array_select$90 = function $$select() { var $iter = $Array_select$90.$$p, block = $iter || nil, $$91, self = this; if ($iter) $Array_select$90.$$p = null; if ($iter) $Array_select$90.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["select"], ($$91 = function(){var self = $$91.$$s || this; return self.$size()}, $$91.$$s = self, $$91.$$arity = 0, $$91)) }; var result = []; for (var i = 0, length = self.length, item, value; i < length; i++) { item = self[i]; value = Opal.yield1(block, item); if (Opal.truthy(value)) { result.push(item); } } return result; ; }, $Array_select$90.$$arity = 0); Opal.def(self, '$select!', $Array_select$excl$92 = function() { var $iter = $Array_select$excl$92.$$p, block = $iter || nil, $$93, self = this; if ($iter) $Array_select$excl$92.$$p = null; if ($iter) $Array_select$excl$92.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["select!"], ($$93 = function(){var self = $$93.$$s || this; return self.$size()}, $$93.$$s = self, $$93.$$arity = 0, $$93)) }; var original = self.length; $send(self, 'keep_if', [], block.$to_proc()); return self.length === original ? nil : self; ; }, $Array_select$excl$92.$$arity = 0); Opal.def(self, '$shift', $Array_shift$94 = function $$shift(count) { var self = this; ; if ($truthy(count === undefined)) { if ($truthy(self.length === 0)) { return nil}; return self.shift();}; count = $$($nesting, 'Opal').$coerce_to(count, $$($nesting, 'Integer'), "to_int"); if ($truthy(count < 0)) { self.$raise($$($nesting, 'ArgumentError'), "negative array size")}; if ($truthy(self.length === 0)) { return []}; return self.splice(0, count);; }, $Array_shift$94.$$arity = -1); Opal.alias(self, "size", "length"); Opal.def(self, '$shuffle', $Array_shuffle$95 = function $$shuffle(rng) { var self = this; ; return self.$dup().$to_a()['$shuffle!'](rng); }, $Array_shuffle$95.$$arity = -1); Opal.def(self, '$shuffle!', $Array_shuffle$excl$96 = function(rng) { var self = this; ; var randgen, i = self.length, j, tmp; if (rng !== undefined) { rng = $$($nesting, 'Opal')['$coerce_to?'](rng, $$($nesting, 'Hash'), "to_hash"); if (rng !== nil) { rng = rng['$[]']("random"); if (rng !== nil && rng['$respond_to?']("rand")) { randgen = rng; } } } while (i) { if (randgen) { j = randgen.$rand(i).$to_int(); if (j < 0) { self.$raise($$($nesting, 'RangeError'), "" + "random number too small " + (j)) } if (j >= i) { self.$raise($$($nesting, 'RangeError'), "" + "random number too big " + (j)) } } else { j = self.$rand(i); } tmp = self[--i]; self[i] = self[j]; self[j] = tmp; } return self; ; }, $Array_shuffle$excl$96.$$arity = -1); Opal.alias(self, "slice", "[]"); Opal.def(self, '$slice!', $Array_slice$excl$97 = function(index, length) { var self = this, result = nil, range = nil, range_start = nil, range_end = nil, start = nil; ; result = nil; if ($truthy(length === undefined)) { if ($truthy($$($nesting, 'Range')['$==='](index))) { range = index; result = self['$[]'](range); range_start = $$($nesting, 'Opal').$coerce_to(range.$begin(), $$($nesting, 'Integer'), "to_int"); range_end = $$($nesting, 'Opal').$coerce_to(range.$end(), $$($nesting, 'Integer'), "to_int"); if (range_start < 0) { range_start += self.length; } if (range_end < 0) { range_end += self.length; } else if (range_end >= self.length) { range_end = self.length - 1; if (range.excl) { range_end += 1; } } var range_length = range_end - range_start; if (range.excl) { range_end -= 1; } else { range_length += 1; } if (range_start < self.length && range_start >= 0 && range_end < self.length && range_end >= 0 && range_length > 0) { self.splice(range_start, range_length); } ; } else { start = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, 'Integer'), "to_int"); if (start < 0) { start += self.length; } if (start < 0 || start >= self.length) { return nil; } result = self[start]; if (start === 0) { self.shift(); } else { self.splice(start, 1); } ; } } else { start = $$($nesting, 'Opal').$coerce_to(index, $$($nesting, 'Integer'), "to_int"); length = $$($nesting, 'Opal').$coerce_to(length, $$($nesting, 'Integer'), "to_int"); if (length < 0) { return nil; } var end = start + length; result = self['$[]'](start, length); if (start < 0) { start += self.length; } if (start + length > self.length) { length = self.length - start; } if (start < self.length && start >= 0) { self.splice(start, length); } ; }; return result; }, $Array_slice$excl$97.$$arity = -2); Opal.def(self, '$sort', $Array_sort$98 = function $$sort() { var $iter = $Array_sort$98.$$p, block = $iter || nil, self = this; if ($iter) $Array_sort$98.$$p = null; if ($iter) $Array_sort$98.$$p = null;; if ($truthy(self.length > 1)) { } else { return self }; if (block === nil) { block = function(a, b) { return (a)['$<=>'](b); }; } return self.slice().sort(function(x, y) { var ret = block(x, y); if (ret === nil) { self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + ((x).$inspect()) + " with " + ((y).$inspect()) + " failed"); } return $rb_gt(ret, 0) ? 1 : ($rb_lt(ret, 0) ? -1 : 0); }); ; }, $Array_sort$98.$$arity = 0); Opal.def(self, '$sort!', $Array_sort$excl$99 = function() { var $iter = $Array_sort$excl$99.$$p, block = $iter || nil, self = this; if ($iter) $Array_sort$excl$99.$$p = null; if ($iter) $Array_sort$excl$99.$$p = null;; var result; if ((block !== nil)) { result = $send((self.slice()), 'sort', [], block.$to_proc()); } else { result = (self.slice()).$sort(); } self.length = 0; for(var i = 0, length = result.length; i < length; i++) { self.push(result[i]); } return self; ; }, $Array_sort$excl$99.$$arity = 0); Opal.def(self, '$sort_by!', $Array_sort_by$excl$100 = function() { var $iter = $Array_sort_by$excl$100.$$p, block = $iter || nil, $$101, self = this; if ($iter) $Array_sort_by$excl$100.$$p = null; if ($iter) $Array_sort_by$excl$100.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["sort_by!"], ($$101 = function(){var self = $$101.$$s || this; return self.$size()}, $$101.$$s = self, $$101.$$arity = 0, $$101)) }; return self.$replace($send(self, 'sort_by', [], block.$to_proc())); }, $Array_sort_by$excl$100.$$arity = 0); Opal.def(self, '$take', $Array_take$102 = function $$take(count) { var self = this; if (count < 0) { self.$raise($$($nesting, 'ArgumentError')); } return self.slice(0, count); }, $Array_take$102.$$arity = 1); Opal.def(self, '$take_while', $Array_take_while$103 = function $$take_while() { var $iter = $Array_take_while$103.$$p, block = $iter || nil, self = this; if ($iter) $Array_take_while$103.$$p = null; if ($iter) $Array_take_while$103.$$p = null;; var result = []; for (var i = 0, length = self.length, item, value; i < length; i++) { item = self[i]; value = block(item); if (value === false || value === nil) { return result; } result.push(item); } return result; ; }, $Array_take_while$103.$$arity = 0); Opal.def(self, '$to_a', $Array_to_a$104 = function $$to_a() { var self = this; return self }, $Array_to_a$104.$$arity = 0); Opal.alias(self, "to_ary", "to_a"); Opal.def(self, '$to_h', $Array_to_h$105 = function $$to_h() { var self = this; var i, len = self.length, ary, key, val, hash = $hash2([], {}); for (i = 0; i < len; i++) { ary = $$($nesting, 'Opal')['$coerce_to?'](self[i], $$($nesting, 'Array'), "to_ary"); if (!ary.$$is_array) { self.$raise($$($nesting, 'TypeError'), "" + "wrong element type " + ((ary).$class()) + " at " + (i) + " (expected array)") } if (ary.length !== 2) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong array length at " + (i) + " (expected 2, was " + ((ary).$length()) + ")") } key = ary[0]; val = ary[1]; Opal.hash_put(hash, key, val); } return hash; }, $Array_to_h$105.$$arity = 0); Opal.alias(self, "to_s", "inspect"); Opal.def(self, '$transpose', $Array_transpose$106 = function $$transpose() { var $$107, self = this, result = nil, max = nil; if ($truthy(self['$empty?']())) { return []}; result = []; max = nil; $send(self, 'each', [], ($$107 = function(row){var self = $$107.$$s || this, $a, $$108; if (row == null) { row = nil; }; row = (function() {if ($truthy($$($nesting, 'Array')['$==='](row))) { return row.$to_a() } else { return $$($nesting, 'Opal').$coerce_to(row, $$($nesting, 'Array'), "to_ary").$to_a() }; return nil; })(); max = ($truthy($a = max) ? $a : row.length); if ($truthy((row.length)['$!='](max))) { self.$raise($$($nesting, 'IndexError'), "" + "element size differs (" + (row.length) + " should be " + (max) + ")")}; return $send((row.length), 'times', [], ($$108 = function(i){var self = $$108.$$s || this, $b, entry = nil, $writer = nil; if (i == null) { i = nil; }; entry = ($truthy($b = result['$[]'](i)) ? $b : (($writer = [i, []]), $send(result, '[]=', Opal.to_a($writer)), $writer[$rb_minus($writer["length"], 1)])); return entry['$<<'](row.$at(i));}, $$108.$$s = self, $$108.$$arity = 1, $$108));}, $$107.$$s = self, $$107.$$arity = 1, $$107)); return result; }, $Array_transpose$106.$$arity = 0); Opal.def(self, '$uniq', $Array_uniq$109 = function $$uniq() { var $iter = $Array_uniq$109.$$p, block = $iter || nil, self = this; if ($iter) $Array_uniq$109.$$p = null; if ($iter) $Array_uniq$109.$$p = null;; var hash = $hash2([], {}), i, length, item, key; if (block === nil) { for (i = 0, length = self.length; i < length; i++) { item = self[i]; if (Opal.hash_get(hash, item) === undefined) { Opal.hash_put(hash, item, item); } } } else { for (i = 0, length = self.length; i < length; i++) { item = self[i]; key = Opal.yield1(block, item); if (Opal.hash_get(hash, key) === undefined) { Opal.hash_put(hash, key, item); } } } return toArraySubclass((hash).$values(), self.$class()); ; }, $Array_uniq$109.$$arity = 0); Opal.def(self, '$uniq!', $Array_uniq$excl$110 = function() { var $iter = $Array_uniq$excl$110.$$p, block = $iter || nil, self = this; if ($iter) $Array_uniq$excl$110.$$p = null; if ($iter) $Array_uniq$excl$110.$$p = null;; var original_length = self.length, hash = $hash2([], {}), i, length, item, key; for (i = 0, length = original_length; i < length; i++) { item = self[i]; key = (block === nil ? item : Opal.yield1(block, item)); if (Opal.hash_get(hash, key) === undefined) { Opal.hash_put(hash, key, item); continue; } self.splice(i, 1); length--; i--; } return self.length === original_length ? nil : self; ; }, $Array_uniq$excl$110.$$arity = 0); Opal.def(self, '$unshift', $Array_unshift$111 = function $$unshift($a) { var $post_args, objects, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); objects = $post_args;; for (var i = objects.length - 1; i >= 0; i--) { self.unshift(objects[i]); } ; return self; }, $Array_unshift$111.$$arity = -1); Opal.alias(self, "prepend", "unshift"); Opal.def(self, '$values_at', $Array_values_at$112 = function $$values_at($a) { var $post_args, args, $$113, self = this, out = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; out = []; $send(args, 'each', [], ($$113 = function(elem){var self = $$113.$$s || this, $$114, finish = nil, start = nil, i = nil; if (elem == null) { elem = nil; }; if ($truthy(elem['$is_a?']($$($nesting, 'Range')))) { finish = $$($nesting, 'Opal').$coerce_to(elem.$last(), $$($nesting, 'Integer'), "to_int"); start = $$($nesting, 'Opal').$coerce_to(elem.$first(), $$($nesting, 'Integer'), "to_int"); if (start < 0) { start = start + self.length; return nil;; } ; if (finish < 0) { finish = finish + self.length; } if (elem['$exclude_end?']()) { finish--; } if (finish < start) { return nil;; } ; return $send(start, 'upto', [finish], ($$114 = function(i){var self = $$114.$$s || this; if (i == null) { i = nil; }; return out['$<<'](self.$at(i));}, $$114.$$s = self, $$114.$$arity = 1, $$114)); } else { i = $$($nesting, 'Opal').$coerce_to(elem, $$($nesting, 'Integer'), "to_int"); return out['$<<'](self.$at(i)); };}, $$113.$$s = self, $$113.$$arity = 1, $$113)); return out; }, $Array_values_at$112.$$arity = -1); Opal.def(self, '$zip', $Array_zip$115 = function $$zip($a) { var $iter = $Array_zip$115.$$p, block = $iter || nil, $post_args, others, $b, self = this; if ($iter) $Array_zip$115.$$p = null; if ($iter) $Array_zip$115.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); others = $post_args;; var result = [], size = self.length, part, o, i, j, jj; for (j = 0, jj = others.length; j < jj; j++) { o = others[j]; if (o.$$is_array) { continue; } if (o.$$is_enumerator) { if (o.$size() === Infinity) { others[j] = o.$take(size); } else { others[j] = o.$to_a(); } continue; } others[j] = ($truthy($b = $$($nesting, 'Opal')['$coerce_to?'](o, $$($nesting, 'Array'), "to_ary")) ? $b : $$($nesting, 'Opal')['$coerce_to!'](o, $$($nesting, 'Enumerator'), "each")).$to_a(); } for (i = 0; i < size; i++) { part = [self[i]]; for (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 (i = 0; i < size; i++) { block(result[i]); } return nil; } return result; ; }, $Array_zip$115.$$arity = -1); Opal.defs(self, '$inherited', $Array_inherited$116 = function $$inherited(klass) { var self = this; klass.$$prototype.$to_a = function() { return this.slice(0, this.length); } }, $Array_inherited$116.$$arity = 1); Opal.def(self, '$instance_variables', $Array_instance_variables$117 = function $$instance_variables() { var $$118, $iter = $Array_instance_variables$117.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Array_instance_variables$117.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } return $send($send(self, Opal.find_super_dispatcher(self, 'instance_variables', $Array_instance_variables$117, false), $zuper, $iter), 'reject', [], ($$118 = function(ivar){var self = $$118.$$s || this, $a; if (ivar == null) { ivar = nil; }; return ($truthy($a = /^@\d+$/.test(ivar)) ? $a : ivar['$==']("@length"));}, $$118.$$s = self, $$118.$$arity = 1, $$118)) }, $Array_instance_variables$117.$$arity = 0); $$($nesting, 'Opal').$pristine(self.$singleton_class(), "allocate"); $$($nesting, 'Opal').$pristine(self, "copy_instance_variables", "initialize_dup"); return (Opal.def(self, '$pack', $Array_pack$119 = function $$pack($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return self.$raise("To use Array#pack, you must first require 'corelib/array/pack'."); }, $Array_pack$119.$$arity = -1), nil) && 'pack'; })($nesting[0], Array, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/hash"] = function(Opal) { function $rb_ge(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2, $truthy = Opal.truthy; Opal.add_stubs(['$require', '$include', '$coerce_to?', '$[]', '$merge!', '$allocate', '$raise', '$coerce_to!', '$each', '$fetch', '$>=', '$>', '$==', '$compare_by_identity', '$lambda?', '$abs', '$arity', '$enum_for', '$size', '$respond_to?', '$class', '$dig', '$new', '$inspect', '$map', '$to_proc', '$flatten', '$eql?', '$default', '$dup', '$default_proc', '$default_proc=', '$-', '$default=', '$proc']); self.$require("corelib/enumerable"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Hash'); var $nesting = [self].concat($parent_nesting), $Hash_$$$1, $Hash_allocate$2, $Hash_try_convert$3, $Hash_initialize$4, $Hash_$eq_eq$5, $Hash_$gt_eq$6, $Hash_$gt$8, $Hash_$lt$9, $Hash_$lt_eq$10, $Hash_$$$11, $Hash_$$$eq$12, $Hash_assoc$13, $Hash_clear$14, $Hash_clone$15, $Hash_compact$16, $Hash_compact$excl$17, $Hash_compare_by_identity$18, $Hash_compare_by_identity$ques$19, $Hash_default$20, $Hash_default$eq$21, $Hash_default_proc$22, $Hash_default_proc$eq$23, $Hash_delete$24, $Hash_delete_if$25, $Hash_dig$27, $Hash_each$28, $Hash_each_key$30, $Hash_each_value$32, $Hash_empty$ques$34, $Hash_fetch$35, $Hash_fetch_values$36, $Hash_flatten$38, $Hash_has_key$ques$39, $Hash_has_value$ques$40, $Hash_hash$41, $Hash_index$42, $Hash_indexes$43, $Hash_inspect$44, $Hash_invert$45, $Hash_keep_if$46, $Hash_keys$48, $Hash_length$49, $Hash_merge$50, $Hash_merge$excl$51, $Hash_rassoc$52, $Hash_rehash$53, $Hash_reject$54, $Hash_reject$excl$56, $Hash_replace$58, $Hash_select$59, $Hash_select$excl$61, $Hash_shift$63, $Hash_slice$64, $Hash_to_a$65, $Hash_to_h$66, $Hash_to_hash$67, $Hash_to_proc$68, $Hash_transform_keys$70, $Hash_transform_keys$excl$72, $Hash_transform_values$74, $Hash_transform_values$excl$76, $Hash_values$78; self.$include($$($nesting, 'Enumerable')); self.$$prototype.$$is_hash = true; Opal.defs(self, '$[]', $Hash_$$$1 = function($a) { var $post_args, argv, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); argv = $post_args;; var hash, argc = argv.length, i; if (argc === 1) { hash = $$($nesting, 'Opal')['$coerce_to?'](argv['$[]'](0), $$($nesting, 'Hash'), "to_hash"); if (hash !== nil) { return self.$allocate()['$merge!'](hash); } argv = $$($nesting, 'Opal')['$coerce_to?'](argv['$[]'](0), $$($nesting, 'Array'), "to_ary"); if (argv === nil) { self.$raise($$($nesting, 'ArgumentError'), "odd number of arguments for Hash") } argc = argv.length; hash = self.$allocate(); for (i = 0; i < argc; i++) { if (!argv[i].$$is_array) continue; switch(argv[i].length) { case 1: hash.$store(argv[i][0], nil); break; case 2: hash.$store(argv[i][0], argv[i][1]); break; default: self.$raise($$($nesting, 'ArgumentError'), "" + "invalid number of elements (" + (argv[i].length) + " for 1..2)") } } return hash; } if (argc % 2 !== 0) { self.$raise($$($nesting, 'ArgumentError'), "odd number of arguments for Hash") } hash = self.$allocate(); for (i = 0; i < argc; i += 2) { hash.$store(argv[i], argv[i + 1]); } return hash; ; }, $Hash_$$$1.$$arity = -1); Opal.defs(self, '$allocate', $Hash_allocate$2 = function $$allocate() { var self = this; var hash = new self.$$constructor(); Opal.hash_init(hash); hash.$$none = nil; hash.$$proc = nil; return hash; }, $Hash_allocate$2.$$arity = 0); Opal.defs(self, '$try_convert', $Hash_try_convert$3 = function $$try_convert(obj) { var self = this; return $$($nesting, 'Opal')['$coerce_to?'](obj, $$($nesting, 'Hash'), "to_hash") }, $Hash_try_convert$3.$$arity = 1); Opal.def(self, '$initialize', $Hash_initialize$4 = function $$initialize(defaults) { var $iter = $Hash_initialize$4.$$p, block = $iter || nil, self = this; if ($iter) $Hash_initialize$4.$$p = null; if ($iter) $Hash_initialize$4.$$p = null;; ; if (defaults !== undefined && block !== nil) { self.$raise($$($nesting, 'ArgumentError'), "wrong number of arguments (1 for 0)") } self.$$none = (defaults === undefined ? nil : defaults); self.$$proc = block; return self; ; }, $Hash_initialize$4.$$arity = -1); Opal.def(self, '$==', $Hash_$eq_eq$5 = function(other) { var self = this; if (self === other) { return true; } if (!other.$$is_hash) { return false; } if (self.$$keys.length !== other.$$keys.length) { return false; } for (var i = 0, keys = self.$$keys, length = keys.length, key, value, other_value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; other_value = other.$$smap[key]; } else { value = key.value; other_value = Opal.hash_get(other, key.key); } if (other_value === undefined || !value['$eql?'](other_value)) { return false; } } return true; }, $Hash_$eq_eq$5.$$arity = 1); Opal.def(self, '$>=', $Hash_$gt_eq$6 = function(other) { var $$7, self = this, result = nil; other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Hash'), "to_hash"); if (self.$$keys.length < other.$$keys.length) { return false } ; result = true; $send(other, 'each', [], ($$7 = function(other_key, other_val){var self = $$7.$$s || this, val = nil; if (other_key == null) { other_key = nil; }; if (other_val == null) { other_val = nil; }; val = self.$fetch(other_key, null); if (val == null || val !== other_val) { result = false; return; } ;}, $$7.$$s = self, $$7.$$arity = 2, $$7)); return result; }, $Hash_$gt_eq$6.$$arity = 1); Opal.def(self, '$>', $Hash_$gt$8 = function(other) { var self = this; other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Hash'), "to_hash"); if (self.$$keys.length <= other.$$keys.length) { return false } ; return $rb_ge(self, other); }, $Hash_$gt$8.$$arity = 1); Opal.def(self, '$<', $Hash_$lt$9 = function(other) { var self = this; other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Hash'), "to_hash"); return $rb_gt(other, self); }, $Hash_$lt$9.$$arity = 1); Opal.def(self, '$<=', $Hash_$lt_eq$10 = function(other) { var self = this; other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Hash'), "to_hash"); return $rb_ge(other, self); }, $Hash_$lt_eq$10.$$arity = 1); Opal.def(self, '$[]', $Hash_$$$11 = function(key) { var self = this; var value = Opal.hash_get(self, key); if (value !== undefined) { return value; } return self.$default(key); }, $Hash_$$$11.$$arity = 1); Opal.def(self, '$[]=', $Hash_$$$eq$12 = function(key, value) { var self = this; Opal.hash_put(self, key, value); return value; }, $Hash_$$$eq$12.$$arity = 2); Opal.def(self, '$assoc', $Hash_assoc$13 = function $$assoc(object) { var self = this; for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) { key = keys[i]; if (key.$$is_string) { if ((key)['$=='](object)) { return [key, self.$$smap[key]]; } } else { if ((key.key)['$=='](object)) { return [key.key, key.value]; } } } return nil; }, $Hash_assoc$13.$$arity = 1); Opal.def(self, '$clear', $Hash_clear$14 = function $$clear() { var self = this; Opal.hash_init(self); return self; }, $Hash_clear$14.$$arity = 0); Opal.def(self, '$clone', $Hash_clone$15 = function $$clone() { var self = this; var hash = new self.$$class(); Opal.hash_init(hash); Opal.hash_clone(self, hash); return hash; }, $Hash_clone$15.$$arity = 0); Opal.def(self, '$compact', $Hash_compact$16 = function $$compact() { var self = this; var hash = Opal.hash(); for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } if (value !== nil) { Opal.hash_put(hash, key, value); } } return hash; }, $Hash_compact$16.$$arity = 0); Opal.def(self, '$compact!', $Hash_compact$excl$17 = function() { var self = this; var changes_were_made = false; for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } if (value === nil) { if (Opal.hash_delete(self, key) !== undefined) { changes_were_made = true; length--; i--; } } } return changes_were_made ? self : nil; }, $Hash_compact$excl$17.$$arity = 0); Opal.def(self, '$compare_by_identity', $Hash_compare_by_identity$18 = function $$compare_by_identity() { var self = this; var i, ii, key, keys = self.$$keys, identity_hash; if (self.$$by_identity) return self; if (self.$$keys.length === 0) { self.$$by_identity = true return self; } identity_hash = $hash2([], {}).$compare_by_identity(); for(i = 0, ii = keys.length; i < ii; i++) { key = keys[i]; if (!key.$$is_string) key = key.key; Opal.hash_put(identity_hash, key, Opal.hash_get(self, key)); } self.$$by_identity = true; self.$$map = identity_hash.$$map; self.$$smap = identity_hash.$$smap; return self; }, $Hash_compare_by_identity$18.$$arity = 0); Opal.def(self, '$compare_by_identity?', $Hash_compare_by_identity$ques$19 = function() { var self = this; return self.$$by_identity === true; }, $Hash_compare_by_identity$ques$19.$$arity = 0); Opal.def(self, '$default', $Hash_default$20 = function(key) { var self = this; ; if (key !== undefined && self.$$proc !== nil && self.$$proc !== undefined) { return self.$$proc.$call(self, key); } if (self.$$none === undefined) { return nil; } return self.$$none; ; }, $Hash_default$20.$$arity = -1); Opal.def(self, '$default=', $Hash_default$eq$21 = function(object) { var self = this; self.$$proc = nil; self.$$none = object; return object; }, $Hash_default$eq$21.$$arity = 1); Opal.def(self, '$default_proc', $Hash_default_proc$22 = function $$default_proc() { var self = this; if (self.$$proc !== undefined) { return self.$$proc; } return nil; }, $Hash_default_proc$22.$$arity = 0); Opal.def(self, '$default_proc=', $Hash_default_proc$eq$23 = function(default_proc) { var self = this; var proc = default_proc; if (proc !== nil) { proc = $$($nesting, 'Opal')['$coerce_to!'](proc, $$($nesting, 'Proc'), "to_proc"); if ((proc)['$lambda?']() && (proc).$arity().$abs() !== 2) { self.$raise($$($nesting, 'TypeError'), "default_proc takes two arguments"); } } self.$$none = nil; self.$$proc = proc; return default_proc; }, $Hash_default_proc$eq$23.$$arity = 1); Opal.def(self, '$delete', $Hash_delete$24 = function(key) { var $iter = $Hash_delete$24.$$p, block = $iter || nil, self = this; if ($iter) $Hash_delete$24.$$p = null; if ($iter) $Hash_delete$24.$$p = null;; var value = Opal.hash_delete(self, key); if (value !== undefined) { return value; } if (block !== nil) { return Opal.yield1(block, key); } return nil; ; }, $Hash_delete$24.$$arity = 1); Opal.def(self, '$delete_if', $Hash_delete_if$25 = function $$delete_if() { var $iter = $Hash_delete_if$25.$$p, block = $iter || nil, $$26, self = this; if ($iter) $Hash_delete_if$25.$$p = null; if ($iter) $Hash_delete_if$25.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["delete_if"], ($$26 = function(){var self = $$26.$$s || this; return self.$size()}, $$26.$$s = self, $$26.$$arity = 0, $$26)) }; for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } obj = block(key, value); if (obj !== false && obj !== nil) { if (Opal.hash_delete(self, key) !== undefined) { length--; i--; } } } return self; ; }, $Hash_delete_if$25.$$arity = 0); Opal.alias(self, "dup", "clone"); Opal.def(self, '$dig', $Hash_dig$27 = function $$dig(key, $a) { var $post_args, keys, self = this, item = nil; $post_args = Opal.slice.call(arguments, 1, arguments.length); keys = $post_args;; item = self['$[]'](key); if (item === nil || keys.length === 0) { return item; } ; if ($truthy(item['$respond_to?']("dig"))) { } else { self.$raise($$($nesting, 'TypeError'), "" + (item.$class()) + " does not have #dig method") }; return $send(item, 'dig', Opal.to_a(keys)); }, $Hash_dig$27.$$arity = -2); Opal.def(self, '$each', $Hash_each$28 = function $$each() { var $iter = $Hash_each$28.$$p, block = $iter || nil, $$29, self = this; if ($iter) $Hash_each$28.$$p = null; if ($iter) $Hash_each$28.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["each"], ($$29 = function(){var self = $$29.$$s || this; return self.$size()}, $$29.$$s = self, $$29.$$arity = 0, $$29)) }; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } Opal.yield1(block, [key, value]); } return self; ; }, $Hash_each$28.$$arity = 0); Opal.def(self, '$each_key', $Hash_each_key$30 = function $$each_key() { var $iter = $Hash_each_key$30.$$p, block = $iter || nil, $$31, self = this; if ($iter) $Hash_each_key$30.$$p = null; if ($iter) $Hash_each_key$30.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["each_key"], ($$31 = function(){var self = $$31.$$s || this; return self.$size()}, $$31.$$s = self, $$31.$$arity = 0, $$31)) }; for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) { key = keys[i]; block(key.$$is_string ? key : key.key); } return self; ; }, $Hash_each_key$30.$$arity = 0); Opal.alias(self, "each_pair", "each"); Opal.def(self, '$each_value', $Hash_each_value$32 = function $$each_value() { var $iter = $Hash_each_value$32.$$p, block = $iter || nil, $$33, self = this; if ($iter) $Hash_each_value$32.$$p = null; if ($iter) $Hash_each_value$32.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["each_value"], ($$33 = function(){var self = $$33.$$s || this; return self.$size()}, $$33.$$s = self, $$33.$$arity = 0, $$33)) }; for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) { key = keys[i]; block(key.$$is_string ? self.$$smap[key] : key.value); } return self; ; }, $Hash_each_value$32.$$arity = 0); Opal.def(self, '$empty?', $Hash_empty$ques$34 = function() { var self = this; return self.$$keys.length === 0; }, $Hash_empty$ques$34.$$arity = 0); Opal.alias(self, "eql?", "=="); Opal.def(self, '$fetch', $Hash_fetch$35 = function $$fetch(key, defaults) { var $iter = $Hash_fetch$35.$$p, block = $iter || nil, self = this; if ($iter) $Hash_fetch$35.$$p = null; if ($iter) $Hash_fetch$35.$$p = null;; ; var value = Opal.hash_get(self, key); if (value !== undefined) { return value; } if (block !== nil) { return block(key); } if (defaults !== undefined) { return defaults; } ; return self.$raise($$($nesting, 'KeyError').$new("" + "key not found: " + (key.$inspect()), $hash2(["key", "receiver"], {"key": key, "receiver": self}))); }, $Hash_fetch$35.$$arity = -2); Opal.def(self, '$fetch_values', $Hash_fetch_values$36 = function $$fetch_values($a) { var $iter = $Hash_fetch_values$36.$$p, block = $iter || nil, $post_args, keys, $$37, self = this; if ($iter) $Hash_fetch_values$36.$$p = null; if ($iter) $Hash_fetch_values$36.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); keys = $post_args;; return $send(keys, 'map', [], ($$37 = function(key){var self = $$37.$$s || this; if (key == null) { key = nil; }; return $send(self, 'fetch', [key], block.$to_proc());}, $$37.$$s = self, $$37.$$arity = 1, $$37)); }, $Hash_fetch_values$36.$$arity = -1); Opal.def(self, '$flatten', $Hash_flatten$38 = function $$flatten(level) { var self = this; if (level == null) { level = 1; }; level = $$($nesting, 'Opal')['$coerce_to!'](level, $$($nesting, 'Integer'), "to_int"); var result = []; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } result.push(key); if (value.$$is_array) { if (level === 1) { result.push(value); continue; } result = result.concat((value).$flatten(level - 2)); continue; } result.push(value); } return result; ; }, $Hash_flatten$38.$$arity = -1); Opal.def(self, '$has_key?', $Hash_has_key$ques$39 = function(key) { var self = this; return Opal.hash_get(self, key) !== undefined; }, $Hash_has_key$ques$39.$$arity = 1); Opal.def(self, '$has_value?', $Hash_has_value$ques$40 = function(value) { var self = this; for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) { key = keys[i]; if (((key.$$is_string ? self.$$smap[key] : key.value))['$=='](value)) { return true; } } return false; }, $Hash_has_value$ques$40.$$arity = 1); Opal.def(self, '$hash', $Hash_hash$41 = function $$hash() { var self = this; var top = (Opal.hash_ids === undefined), hash_id = self.$object_id(), result = ['Hash'], key, item; try { if (top) { Opal.hash_ids = Object.create(null); } if (Opal[hash_id]) { return 'self'; } for (key in Opal.hash_ids) { item = Opal.hash_ids[key]; if (self['$eql?'](item)) { return 'self'; } } Opal.hash_ids[hash_id] = self; for (var i = 0, keys = self.$$keys, length = keys.length; i < length; i++) { key = keys[i]; if (key.$$is_string) { result.push([key, self.$$smap[key].$hash()]); } else { result.push([key.key_hash, key.value.$hash()]); } } return result.sort().join(); } finally { if (top) { Opal.hash_ids = undefined; } } }, $Hash_hash$41.$$arity = 0); Opal.alias(self, "include?", "has_key?"); Opal.def(self, '$index', $Hash_index$42 = function $$index(object) { var self = this; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } if ((value)['$=='](object)) { return key; } } return nil; }, $Hash_index$42.$$arity = 1); Opal.def(self, '$indexes', $Hash_indexes$43 = function $$indexes($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var result = []; for (var i = 0, length = args.length, key, value; i < length; i++) { key = args[i]; value = Opal.hash_get(self, key); if (value === undefined) { result.push(self.$default()); continue; } result.push(value); } return result; ; }, $Hash_indexes$43.$$arity = -1); Opal.alias(self, "indices", "indexes"); var inspect_ids; Opal.def(self, '$inspect', $Hash_inspect$44 = function $$inspect() { var self = this; var top = (inspect_ids === undefined), hash_id = self.$object_id(), result = []; try { if (top) { inspect_ids = {}; } if (inspect_ids.hasOwnProperty(hash_id)) { return '{...}'; } inspect_ids[hash_id] = true; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } result.push(key.$inspect() + '=>' + value.$inspect()); } return '{' + result.join(', ') + '}'; } finally { if (top) { inspect_ids = undefined; } } }, $Hash_inspect$44.$$arity = 0); Opal.def(self, '$invert', $Hash_invert$45 = function $$invert() { var self = this; var hash = Opal.hash(); for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } Opal.hash_put(hash, value, key); } return hash; }, $Hash_invert$45.$$arity = 0); Opal.def(self, '$keep_if', $Hash_keep_if$46 = function $$keep_if() { var $iter = $Hash_keep_if$46.$$p, block = $iter || nil, $$47, self = this; if ($iter) $Hash_keep_if$46.$$p = null; if ($iter) $Hash_keep_if$46.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["keep_if"], ($$47 = function(){var self = $$47.$$s || this; return self.$size()}, $$47.$$s = self, $$47.$$arity = 0, $$47)) }; for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } obj = block(key, value); if (obj === false || obj === nil) { if (Opal.hash_delete(self, key) !== undefined) { length--; i--; } } } return self; ; }, $Hash_keep_if$46.$$arity = 0); Opal.alias(self, "key", "index"); Opal.alias(self, "key?", "has_key?"); Opal.def(self, '$keys', $Hash_keys$48 = function $$keys() { var self = this; var result = []; for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) { key = keys[i]; if (key.$$is_string) { result.push(key); } else { result.push(key.key); } } return result; }, $Hash_keys$48.$$arity = 0); Opal.def(self, '$length', $Hash_length$49 = function $$length() { var self = this; return self.$$keys.length; }, $Hash_length$49.$$arity = 0); Opal.alias(self, "member?", "has_key?"); Opal.def(self, '$merge', $Hash_merge$50 = function $$merge(other) { var $iter = $Hash_merge$50.$$p, block = $iter || nil, self = this; if ($iter) $Hash_merge$50.$$p = null; if ($iter) $Hash_merge$50.$$p = null;; return $send(self.$dup(), 'merge!', [other], block.$to_proc()); }, $Hash_merge$50.$$arity = 1); Opal.def(self, '$merge!', $Hash_merge$excl$51 = function(other) { var $iter = $Hash_merge$excl$51.$$p, block = $iter || nil, self = this; if ($iter) $Hash_merge$excl$51.$$p = null; if ($iter) $Hash_merge$excl$51.$$p = null;; if (!other.$$is_hash) { other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Hash'), "to_hash"); } var i, other_keys = other.$$keys, length = other_keys.length, key, value, other_value; if (block === nil) { for (i = 0; i < length; i++) { key = other_keys[i]; if (key.$$is_string) { other_value = other.$$smap[key]; } else { other_value = key.value; key = key.key; } Opal.hash_put(self, key, other_value); } return self; } for (i = 0; i < length; i++) { key = other_keys[i]; if (key.$$is_string) { other_value = other.$$smap[key]; } else { other_value = key.value; key = key.key; } value = Opal.hash_get(self, key); if (value === undefined) { Opal.hash_put(self, key, other_value); continue; } Opal.hash_put(self, key, block(key, value, other_value)); } return self; ; }, $Hash_merge$excl$51.$$arity = 1); Opal.def(self, '$rassoc', $Hash_rassoc$52 = function $$rassoc(object) { var self = this; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } if ((value)['$=='](object)) { return [key, value]; } } return nil; }, $Hash_rassoc$52.$$arity = 1); Opal.def(self, '$rehash', $Hash_rehash$53 = function $$rehash() { var self = this; Opal.hash_rehash(self); return self; }, $Hash_rehash$53.$$arity = 0); Opal.def(self, '$reject', $Hash_reject$54 = function $$reject() { var $iter = $Hash_reject$54.$$p, block = $iter || nil, $$55, self = this; if ($iter) $Hash_reject$54.$$p = null; if ($iter) $Hash_reject$54.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["reject"], ($$55 = function(){var self = $$55.$$s || this; return self.$size()}, $$55.$$s = self, $$55.$$arity = 0, $$55)) }; var hash = Opal.hash(); for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } obj = block(key, value); if (obj === false || obj === nil) { Opal.hash_put(hash, key, value); } } return hash; ; }, $Hash_reject$54.$$arity = 0); Opal.def(self, '$reject!', $Hash_reject$excl$56 = function() { var $iter = $Hash_reject$excl$56.$$p, block = $iter || nil, $$57, self = this; if ($iter) $Hash_reject$excl$56.$$p = null; if ($iter) $Hash_reject$excl$56.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["reject!"], ($$57 = function(){var self = $$57.$$s || this; return self.$size()}, $$57.$$s = self, $$57.$$arity = 0, $$57)) }; var changes_were_made = false; for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } obj = block(key, value); if (obj !== false && obj !== nil) { if (Opal.hash_delete(self, key) !== undefined) { changes_were_made = true; length--; i--; } } } return changes_were_made ? self : nil; ; }, $Hash_reject$excl$56.$$arity = 0); Opal.def(self, '$replace', $Hash_replace$58 = function $$replace(other) { var self = this, $writer = nil; other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Hash'), "to_hash"); Opal.hash_init(self); for (var i = 0, other_keys = other.$$keys, length = other_keys.length, key, value, other_value; i < length; i++) { key = other_keys[i]; if (key.$$is_string) { other_value = other.$$smap[key]; } else { other_value = key.value; key = key.key; } Opal.hash_put(self, key, other_value); } ; if ($truthy(other.$default_proc())) { $writer = [other.$default_proc()]; $send(self, 'default_proc=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; } else { $writer = [other.$default()]; $send(self, 'default=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; }; return self; }, $Hash_replace$58.$$arity = 1); Opal.def(self, '$select', $Hash_select$59 = function $$select() { var $iter = $Hash_select$59.$$p, block = $iter || nil, $$60, self = this; if ($iter) $Hash_select$59.$$p = null; if ($iter) $Hash_select$59.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["select"], ($$60 = function(){var self = $$60.$$s || this; return self.$size()}, $$60.$$s = self, $$60.$$arity = 0, $$60)) }; var hash = Opal.hash(); for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } obj = block(key, value); if (obj !== false && obj !== nil) { Opal.hash_put(hash, key, value); } } return hash; ; }, $Hash_select$59.$$arity = 0); Opal.def(self, '$select!', $Hash_select$excl$61 = function() { var $iter = $Hash_select$excl$61.$$p, block = $iter || nil, $$62, self = this; if ($iter) $Hash_select$excl$61.$$p = null; if ($iter) $Hash_select$excl$61.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["select!"], ($$62 = function(){var self = $$62.$$s || this; return self.$size()}, $$62.$$s = self, $$62.$$arity = 0, $$62)) }; var result = nil; for (var i = 0, keys = self.$$keys, length = keys.length, key, value, obj; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } obj = block(key, value); if (obj === false || obj === nil) { if (Opal.hash_delete(self, key) !== undefined) { length--; i--; } result = self; } } return result; ; }, $Hash_select$excl$61.$$arity = 0); Opal.def(self, '$shift', $Hash_shift$63 = function $$shift() { var self = this; var keys = self.$$keys, key; if (keys.length > 0) { key = keys[0]; key = key.$$is_string ? key : key.key; return [key, Opal.hash_delete(self, key)]; } return self.$default(nil); }, $Hash_shift$63.$$arity = 0); Opal.alias(self, "size", "length"); Opal.def(self, '$slice', $Hash_slice$64 = function $$slice($a) { var $post_args, keys, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); keys = $post_args;; var result = Opal.hash(); for (var i = 0, length = keys.length; i < length; i++) { var key = keys[i], value = Opal.hash_get(self, key); if (value !== undefined) { Opal.hash_put(result, key, value); } } return result; ; }, $Hash_slice$64.$$arity = -1); Opal.alias(self, "store", "[]="); Opal.def(self, '$to_a', $Hash_to_a$65 = function $$to_a() { var self = this; var result = []; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } result.push([key, value]); } return result; }, $Hash_to_a$65.$$arity = 0); Opal.def(self, '$to_h', $Hash_to_h$66 = function $$to_h() { var self = this; if (self.$$class === Opal.Hash) { return self; } var hash = new Opal.Hash(); Opal.hash_init(hash); Opal.hash_clone(self, hash); return hash; }, $Hash_to_h$66.$$arity = 0); Opal.def(self, '$to_hash', $Hash_to_hash$67 = function $$to_hash() { var self = this; return self }, $Hash_to_hash$67.$$arity = 0); Opal.def(self, '$to_proc', $Hash_to_proc$68 = function $$to_proc() { var $$69, self = this; return $send(self, 'proc', [], ($$69 = function(key){var self = $$69.$$s || this; ; if (key == null) { self.$raise($$($nesting, 'ArgumentError'), "no key given") } ; return self['$[]'](key);}, $$69.$$s = self, $$69.$$arity = -1, $$69)) }, $Hash_to_proc$68.$$arity = 0); Opal.alias(self, "to_s", "inspect"); Opal.def(self, '$transform_keys', $Hash_transform_keys$70 = function $$transform_keys() { var $iter = $Hash_transform_keys$70.$$p, block = $iter || nil, $$71, self = this; if ($iter) $Hash_transform_keys$70.$$p = null; if ($iter) $Hash_transform_keys$70.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["transform_keys"], ($$71 = function(){var self = $$71.$$s || this; return self.$size()}, $$71.$$s = self, $$71.$$arity = 0, $$71)) }; var result = Opal.hash(); for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } key = Opal.yield1(block, key); Opal.hash_put(result, key, value); } return result; ; }, $Hash_transform_keys$70.$$arity = 0); Opal.def(self, '$transform_keys!', $Hash_transform_keys$excl$72 = function() { var $iter = $Hash_transform_keys$excl$72.$$p, block = $iter || nil, $$73, self = this; if ($iter) $Hash_transform_keys$excl$72.$$p = null; if ($iter) $Hash_transform_keys$excl$72.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["transform_keys!"], ($$73 = function(){var self = $$73.$$s || this; return self.$size()}, $$73.$$s = self, $$73.$$arity = 0, $$73)) }; var keys = Opal.slice.call(self.$$keys), i, length = keys.length, key, value, new_key; for (i = 0; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } new_key = Opal.yield1(block, key); Opal.hash_delete(self, key); Opal.hash_put(self, new_key, value); } return self; ; }, $Hash_transform_keys$excl$72.$$arity = 0); Opal.def(self, '$transform_values', $Hash_transform_values$74 = function $$transform_values() { var $iter = $Hash_transform_values$74.$$p, block = $iter || nil, $$75, self = this; if ($iter) $Hash_transform_values$74.$$p = null; if ($iter) $Hash_transform_values$74.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["transform_values"], ($$75 = function(){var self = $$75.$$s || this; return self.$size()}, $$75.$$s = self, $$75.$$arity = 0, $$75)) }; var result = Opal.hash(); for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } value = Opal.yield1(block, value); Opal.hash_put(result, key, value); } return result; ; }, $Hash_transform_values$74.$$arity = 0); Opal.def(self, '$transform_values!', $Hash_transform_values$excl$76 = function() { var $iter = $Hash_transform_values$excl$76.$$p, block = $iter || nil, $$77, self = this; if ($iter) $Hash_transform_values$excl$76.$$p = null; if ($iter) $Hash_transform_values$excl$76.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["transform_values!"], ($$77 = function(){var self = $$77.$$s || this; return self.$size()}, $$77.$$s = self, $$77.$$arity = 0, $$77)) }; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } value = Opal.yield1(block, value); Opal.hash_put(self, key, value); } return self; ; }, $Hash_transform_values$excl$76.$$arity = 0); Opal.alias(self, "update", "merge!"); Opal.alias(self, "value?", "has_value?"); Opal.alias(self, "values_at", "indexes"); return (Opal.def(self, '$values', $Hash_values$78 = function $$values() { var self = this; var result = []; for (var i = 0, keys = self.$$keys, length = keys.length, key; i < length; i++) { key = keys[i]; if (key.$$is_string) { result.push(self.$$smap[key]); } else { result.push(key.value); } } return result; }, $Hash_values$78.$$arity = 0), nil) && 'values'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/number"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_le(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs); } function $rb_ge(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$require', '$bridge', '$raise', '$name', '$class', '$Float', '$respond_to?', '$coerce_to!', '$__coerced__', '$===', '$!', '$>', '$**', '$new', '$<', '$to_f', '$==', '$nan?', '$infinite?', '$enum_for', '$+', '$-', '$gcd', '$lcm', '$%', '$/', '$frexp', '$to_i', '$ldexp', '$rationalize', '$*', '$<<', '$to_r', '$truncate', '$-@', '$size', '$<=', '$>=', '$<=>', '$compare', '$any?']); self.$require("corelib/numeric"); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Number'); var $nesting = [self].concat($parent_nesting), $Number_coerce$2, $Number___id__$3, $Number_$plus$4, $Number_$minus$5, $Number_$$6, $Number_$slash$7, $Number_$percent$8, $Number_$$9, $Number_$$10, $Number_$$11, $Number_$lt$12, $Number_$lt_eq$13, $Number_$gt$14, $Number_$gt_eq$15, $Number_$lt_eq_gt$16, $Number_$lt$lt$17, $Number_$gt$gt$18, $Number_$$$19, $Number_$plus$$20, $Number_$minus$$21, $Number_$$22, $Number_$$$23, $Number_$eq_eq_eq$24, $Number_$eq_eq$25, $Number_abs$26, $Number_abs2$27, $Number_allbits$ques$28, $Number_anybits$ques$29, $Number_angle$30, $Number_bit_length$31, $Number_ceil$32, $Number_chr$33, $Number_denominator$34, $Number_downto$35, $Number_equal$ques$37, $Number_even$ques$38, $Number_floor$39, $Number_gcd$40, $Number_gcdlcm$41, $Number_integer$ques$42, $Number_is_a$ques$43, $Number_instance_of$ques$44, $Number_lcm$45, $Number_next$46, $Number_nobits$ques$47, $Number_nonzero$ques$48, $Number_numerator$49, $Number_odd$ques$50, $Number_ord$51, $Number_pow$52, $Number_pred$53, $Number_quo$54, $Number_rationalize$55, $Number_remainder$56, $Number_round$57, $Number_step$58, $Number_times$60, $Number_to_f$62, $Number_to_i$63, $Number_to_r$64, $Number_to_s$65, $Number_truncate$66, $Number_digits$67, $Number_divmod$68, $Number_upto$69, $Number_zero$ques$71, $Number_size$72, $Number_nan$ques$73, $Number_finite$ques$74, $Number_infinite$ques$75, $Number_positive$ques$76, $Number_negative$ques$77; $$($nesting, 'Opal').$bridge(Number, self); Opal.defineProperty(self.$$prototype, '$$is_number', true); self.$$is_number_class = true; (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $allocate$1; Opal.def(self, '$allocate', $allocate$1 = function $$allocate() { var self = this; return self.$raise($$($nesting, 'TypeError'), "" + "allocator undefined for " + (self.$name())) }, $allocate$1.$$arity = 0); Opal.udef(self, '$' + "new");; return nil;; })(Opal.get_singleton_class(self), $nesting); Opal.def(self, '$coerce', $Number_coerce$2 = function $$coerce(other) { var self = this; if (other === nil) { self.$raise($$($nesting, 'TypeError'), "" + "can't convert " + (other.$class()) + " into Float"); } else if (other.$$is_string) { return [self.$Float(other), self]; } else if (other['$respond_to?']("to_f")) { return [$$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Float'), "to_f"), self]; } else if (other.$$is_number) { return [other, self]; } else { self.$raise($$($nesting, 'TypeError'), "" + "can't convert " + (other.$class()) + " into Float"); } }, $Number_coerce$2.$$arity = 1); Opal.def(self, '$__id__', $Number___id__$3 = function $$__id__() { var self = this; return (self * 2) + 1; }, $Number___id__$3.$$arity = 0); Opal.alias(self, "object_id", "__id__"); Opal.def(self, '$+', $Number_$plus$4 = function(other) { var self = this; if (other.$$is_number) { return self + other; } else { return self.$__coerced__("+", other); } }, $Number_$plus$4.$$arity = 1); Opal.def(self, '$-', $Number_$minus$5 = function(other) { var self = this; if (other.$$is_number) { return self - other; } else { return self.$__coerced__("-", other); } }, $Number_$minus$5.$$arity = 1); Opal.def(self, '$*', $Number_$$6 = function(other) { var self = this; if (other.$$is_number) { return self * other; } else { return self.$__coerced__("*", other); } }, $Number_$$6.$$arity = 1); Opal.def(self, '$/', $Number_$slash$7 = function(other) { var self = this; if (other.$$is_number) { return self / other; } else { return self.$__coerced__("/", other); } }, $Number_$slash$7.$$arity = 1); Opal.alias(self, "fdiv", "/"); Opal.def(self, '$%', $Number_$percent$8 = function(other) { var self = this; if (other.$$is_number) { if (other == -Infinity) { return other; } else if (other == 0) { self.$raise($$($nesting, 'ZeroDivisionError'), "divided by 0"); } else if (other < 0 || self < 0) { return (self % other + other) % other; } else { return self % other; } } else { return self.$__coerced__("%", other); } }, $Number_$percent$8.$$arity = 1); Opal.def(self, '$&', $Number_$$9 = function(other) { var self = this; if (other.$$is_number) { return self & other; } else { return self.$__coerced__("&", other); } }, $Number_$$9.$$arity = 1); Opal.def(self, '$|', $Number_$$10 = function(other) { var self = this; if (other.$$is_number) { return self | other; } else { return self.$__coerced__("|", other); } }, $Number_$$10.$$arity = 1); Opal.def(self, '$^', $Number_$$11 = function(other) { var self = this; if (other.$$is_number) { return self ^ other; } else { return self.$__coerced__("^", other); } }, $Number_$$11.$$arity = 1); Opal.def(self, '$<', $Number_$lt$12 = function(other) { var self = this; if (other.$$is_number) { return self < other; } else { return self.$__coerced__("<", other); } }, $Number_$lt$12.$$arity = 1); Opal.def(self, '$<=', $Number_$lt_eq$13 = function(other) { var self = this; if (other.$$is_number) { return self <= other; } else { return self.$__coerced__("<=", other); } }, $Number_$lt_eq$13.$$arity = 1); Opal.def(self, '$>', $Number_$gt$14 = function(other) { var self = this; if (other.$$is_number) { return self > other; } else { return self.$__coerced__(">", other); } }, $Number_$gt$14.$$arity = 1); Opal.def(self, '$>=', $Number_$gt_eq$15 = function(other) { var self = this; if (other.$$is_number) { return self >= other; } else { return self.$__coerced__(">=", other); } }, $Number_$gt_eq$15.$$arity = 1); var spaceship_operator = function(self, other) { if (other.$$is_number) { if (isNaN(self) || isNaN(other)) { return nil; } if (self > other) { return 1; } else if (self < other) { return -1; } else { return 0; } } else { return self.$__coerced__("<=>", other); } } ; Opal.def(self, '$<=>', $Number_$lt_eq_gt$16 = function(other) { var self = this; try { return spaceship_operator(self, other); } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'ArgumentError')])) { try { return nil } finally { Opal.pop_exception() } } else { throw $err; } } }, $Number_$lt_eq_gt$16.$$arity = 1); Opal.def(self, '$<<', $Number_$lt$lt$17 = function(count) { var self = this; count = $$($nesting, 'Opal')['$coerce_to!'](count, $$($nesting, 'Integer'), "to_int"); return count > 0 ? self << count : self >> -count; }, $Number_$lt$lt$17.$$arity = 1); Opal.def(self, '$>>', $Number_$gt$gt$18 = function(count) { var self = this; count = $$($nesting, 'Opal')['$coerce_to!'](count, $$($nesting, 'Integer'), "to_int"); return count > 0 ? self >> count : self << -count; }, $Number_$gt$gt$18.$$arity = 1); Opal.def(self, '$[]', $Number_$$$19 = function(bit) { var self = this; bit = $$($nesting, 'Opal')['$coerce_to!'](bit, $$($nesting, 'Integer'), "to_int"); if (bit < 0) { return 0; } if (bit >= 32) { return self < 0 ? 1 : 0; } return (self >> bit) & 1; ; }, $Number_$$$19.$$arity = 1); Opal.def(self, '$+@', $Number_$plus$$20 = function() { var self = this; return +self; }, $Number_$plus$$20.$$arity = 0); Opal.def(self, '$-@', $Number_$minus$$21 = function() { var self = this; return -self; }, $Number_$minus$$21.$$arity = 0); Opal.def(self, '$~', $Number_$$22 = function() { var self = this; return ~self; }, $Number_$$22.$$arity = 0); Opal.def(self, '$**', $Number_$$$23 = function(other) { var $a, $b, self = this; if ($truthy($$($nesting, 'Integer')['$==='](other))) { if ($truthy(($truthy($a = $$($nesting, 'Integer')['$==='](self)['$!']()) ? $a : $rb_gt(other, 0)))) { return Math.pow(self, other); } else { return $$($nesting, 'Rational').$new(self, 1)['$**'](other) } } else if ($truthy((($a = $rb_lt(self, 0)) ? ($truthy($b = $$($nesting, 'Float')['$==='](other)) ? $b : $$($nesting, 'Rational')['$==='](other)) : $rb_lt(self, 0)))) { return $$($nesting, 'Complex').$new(self, 0)['$**'](other.$to_f()) } else if ($truthy(other.$$is_number != null)) { return Math.pow(self, other); } else { return self.$__coerced__("**", other) } }, $Number_$$$23.$$arity = 1); Opal.def(self, '$===', $Number_$eq_eq_eq$24 = function(other) { var self = this; if (other.$$is_number) { return self.valueOf() === other.valueOf(); } else if (other['$respond_to?']("==")) { return other['$=='](self); } else { return false; } }, $Number_$eq_eq_eq$24.$$arity = 1); Opal.def(self, '$==', $Number_$eq_eq$25 = function(other) { var self = this; if (other.$$is_number) { return self.valueOf() === other.valueOf(); } else if (other['$respond_to?']("==")) { return other['$=='](self); } else { return false; } }, $Number_$eq_eq$25.$$arity = 1); Opal.def(self, '$abs', $Number_abs$26 = function $$abs() { var self = this; return Math.abs(self); }, $Number_abs$26.$$arity = 0); Opal.def(self, '$abs2', $Number_abs2$27 = function $$abs2() { var self = this; return Math.abs(self * self); }, $Number_abs2$27.$$arity = 0); Opal.def(self, '$allbits?', $Number_allbits$ques$28 = function(mask) { var self = this; mask = $$($nesting, 'Opal')['$coerce_to!'](mask, $$($nesting, 'Integer'), "to_int"); return (self & mask) == mask;; }, $Number_allbits$ques$28.$$arity = 1); Opal.def(self, '$anybits?', $Number_anybits$ques$29 = function(mask) { var self = this; mask = $$($nesting, 'Opal')['$coerce_to!'](mask, $$($nesting, 'Integer'), "to_int"); return (self & mask) !== 0;; }, $Number_anybits$ques$29.$$arity = 1); Opal.def(self, '$angle', $Number_angle$30 = function $$angle() { var self = this; if ($truthy(self['$nan?']())) { return self}; if (self == 0) { if (1 / self > 0) { return 0; } else { return Math.PI; } } else if (self < 0) { return Math.PI; } else { return 0; } ; }, $Number_angle$30.$$arity = 0); Opal.alias(self, "arg", "angle"); Opal.alias(self, "phase", "angle"); Opal.def(self, '$bit_length', $Number_bit_length$31 = function $$bit_length() { var self = this; if ($truthy($$($nesting, 'Integer')['$==='](self))) { } else { self.$raise($$($nesting, 'NoMethodError').$new("" + "undefined method `bit_length` for " + (self) + ":Float", "bit_length")) }; if (self === 0 || self === -1) { return 0; } var result = 0, value = self < 0 ? ~self : self; while (value != 0) { result += 1; value >>>= 1; } return result; ; }, $Number_bit_length$31.$$arity = 0); Opal.def(self, '$ceil', $Number_ceil$32 = function $$ceil(ndigits) { var self = this; if (ndigits == null) { ndigits = 0; }; var f = self.$to_f(); if (f % 1 === 0 && ndigits >= 0) { return f; } var factor = Math.pow(10, ndigits), result = Math.ceil(f * factor) / factor; if (f % 1 === 0) { result = Math.round(result); } return result; ; }, $Number_ceil$32.$$arity = -1); Opal.def(self, '$chr', $Number_chr$33 = function $$chr(encoding) { var self = this; ; return String.fromCharCode(self);; }, $Number_chr$33.$$arity = -1); Opal.def(self, '$denominator', $Number_denominator$34 = function $$denominator() { var $a, $iter = $Number_denominator$34.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Number_denominator$34.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($truthy(($truthy($a = self['$nan?']()) ? $a : self['$infinite?']()))) { return 1 } else { return $send(self, Opal.find_super_dispatcher(self, 'denominator', $Number_denominator$34, false), $zuper, $iter) } }, $Number_denominator$34.$$arity = 0); Opal.def(self, '$downto', $Number_downto$35 = function $$downto(stop) { var $iter = $Number_downto$35.$$p, block = $iter || nil, $$36, self = this; if ($iter) $Number_downto$35.$$p = null; if ($iter) $Number_downto$35.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["downto", stop], ($$36 = function(){var self = $$36.$$s || this; if ($truthy($$($nesting, 'Numeric')['$==='](stop))) { } else { self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") }; if ($truthy($rb_gt(stop, self))) { return 0 } else { return $rb_plus($rb_minus(self, stop), 1) };}, $$36.$$s = self, $$36.$$arity = 0, $$36)) }; if (!stop.$$is_number) { self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") } for (var i = self; i >= stop; i--) { block(i); } ; return self; }, $Number_downto$35.$$arity = 1); Opal.alias(self, "eql?", "=="); Opal.def(self, '$equal?', $Number_equal$ques$37 = function(other) { var $a, self = this; return ($truthy($a = self['$=='](other)) ? $a : isNaN(self) && isNaN(other)) }, $Number_equal$ques$37.$$arity = 1); Opal.def(self, '$even?', $Number_even$ques$38 = function() { var self = this; return self % 2 === 0; }, $Number_even$ques$38.$$arity = 0); Opal.def(self, '$floor', $Number_floor$39 = function $$floor(ndigits) { var self = this; if (ndigits == null) { ndigits = 0; }; var f = self.$to_f(); if (f % 1 === 0 && ndigits >= 0) { return f; } var factor = Math.pow(10, ndigits), result = Math.floor(f * factor) / factor; if (f % 1 === 0) { result = Math.round(result); } return result; ; }, $Number_floor$39.$$arity = -1); Opal.def(self, '$gcd', $Number_gcd$40 = function $$gcd(other) { var self = this; if ($truthy($$($nesting, 'Integer')['$==='](other))) { } else { self.$raise($$($nesting, '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; ; }, $Number_gcd$40.$$arity = 1); Opal.def(self, '$gcdlcm', $Number_gcdlcm$41 = function $$gcdlcm(other) { var self = this; return [self.$gcd(), self.$lcm()] }, $Number_gcdlcm$41.$$arity = 1); Opal.def(self, '$integer?', $Number_integer$ques$42 = function() { var self = this; return self % 1 === 0; }, $Number_integer$ques$42.$$arity = 0); Opal.def(self, '$is_a?', $Number_is_a$ques$43 = function(klass) { var $a, $iter = $Number_is_a$ques$43.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Number_is_a$ques$43.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($truthy((($a = klass['$==']($$($nesting, 'Integer'))) ? $$($nesting, 'Integer')['$==='](self) : klass['$==']($$($nesting, 'Integer'))))) { return true}; if ($truthy((($a = klass['$==']($$($nesting, 'Integer'))) ? $$($nesting, 'Integer')['$==='](self) : klass['$==']($$($nesting, 'Integer'))))) { return true}; if ($truthy((($a = klass['$==']($$($nesting, 'Float'))) ? $$($nesting, 'Float')['$==='](self) : klass['$==']($$($nesting, 'Float'))))) { return true}; return $send(self, Opal.find_super_dispatcher(self, 'is_a?', $Number_is_a$ques$43, false), $zuper, $iter); }, $Number_is_a$ques$43.$$arity = 1); Opal.alias(self, "kind_of?", "is_a?"); Opal.def(self, '$instance_of?', $Number_instance_of$ques$44 = function(klass) { var $a, $iter = $Number_instance_of$ques$44.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Number_instance_of$ques$44.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($truthy((($a = klass['$==']($$($nesting, 'Integer'))) ? $$($nesting, 'Integer')['$==='](self) : klass['$==']($$($nesting, 'Integer'))))) { return true}; if ($truthy((($a = klass['$==']($$($nesting, 'Integer'))) ? $$($nesting, 'Integer')['$==='](self) : klass['$==']($$($nesting, 'Integer'))))) { return true}; if ($truthy((($a = klass['$==']($$($nesting, 'Float'))) ? $$($nesting, 'Float')['$==='](self) : klass['$==']($$($nesting, 'Float'))))) { return true}; return $send(self, Opal.find_super_dispatcher(self, 'instance_of?', $Number_instance_of$ques$44, false), $zuper, $iter); }, $Number_instance_of$ques$44.$$arity = 1); Opal.def(self, '$lcm', $Number_lcm$45 = function $$lcm(other) { var self = this; if ($truthy($$($nesting, 'Integer')['$==='](other))) { } else { self.$raise($$($nesting, 'TypeError'), "not an integer") }; if (self == 0 || other == 0) { return 0; } else { return Math.abs(self * other / self.$gcd(other)); } ; }, $Number_lcm$45.$$arity = 1); Opal.alias(self, "magnitude", "abs"); Opal.alias(self, "modulo", "%"); Opal.def(self, '$next', $Number_next$46 = function $$next() { var self = this; return self + 1; }, $Number_next$46.$$arity = 0); Opal.def(self, '$nobits?', $Number_nobits$ques$47 = function(mask) { var self = this; mask = $$($nesting, 'Opal')['$coerce_to!'](mask, $$($nesting, 'Integer'), "to_int"); return (self & mask) == 0;; }, $Number_nobits$ques$47.$$arity = 1); Opal.def(self, '$nonzero?', $Number_nonzero$ques$48 = function() { var self = this; return self == 0 ? nil : self; }, $Number_nonzero$ques$48.$$arity = 0); Opal.def(self, '$numerator', $Number_numerator$49 = function $$numerator() { var $a, $iter = $Number_numerator$49.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Number_numerator$49.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($truthy(($truthy($a = self['$nan?']()) ? $a : self['$infinite?']()))) { return self } else { return $send(self, Opal.find_super_dispatcher(self, 'numerator', $Number_numerator$49, false), $zuper, $iter) } }, $Number_numerator$49.$$arity = 0); Opal.def(self, '$odd?', $Number_odd$ques$50 = function() { var self = this; return self % 2 !== 0; }, $Number_odd$ques$50.$$arity = 0); Opal.def(self, '$ord', $Number_ord$51 = function $$ord() { var self = this; return self }, $Number_ord$51.$$arity = 0); Opal.def(self, '$pow', $Number_pow$52 = function $$pow(b, m) { var self = this; ; if (self == 0) { self.$raise($$($nesting, 'ZeroDivisionError'), "divided by 0") } if (m === undefined) { return self['$**'](b); } else { if (!($$($nesting, 'Integer')['$==='](b))) { self.$raise($$($nesting, 'TypeError'), "Integer#pow() 2nd argument not allowed unless a 1st argument is integer") } if (b < 0) { self.$raise($$($nesting, 'TypeError'), "Integer#pow() 1st argument cannot be negative when 2nd argument specified") } if (!($$($nesting, 'Integer')['$==='](m))) { self.$raise($$($nesting, 'TypeError'), "Integer#pow() 2nd argument not allowed unless all arguments are integers") } if (m === 0) { self.$raise($$($nesting, 'ZeroDivisionError'), "divided by 0") } return self['$**'](b)['$%'](m) } ; }, $Number_pow$52.$$arity = -2); Opal.def(self, '$pred', $Number_pred$53 = function $$pred() { var self = this; return self - 1; }, $Number_pred$53.$$arity = 0); Opal.def(self, '$quo', $Number_quo$54 = function $$quo(other) { var $iter = $Number_quo$54.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Number_quo$54.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($truthy($$($nesting, 'Integer')['$==='](self))) { return $send(self, Opal.find_super_dispatcher(self, 'quo', $Number_quo$54, false), $zuper, $iter) } else { return $rb_divide(self, other) } }, $Number_quo$54.$$arity = 1); Opal.def(self, '$rationalize', $Number_rationalize$55 = function $$rationalize(eps) { var $a, $b, self = this, f = nil, n = nil; ; if (arguments.length > 1) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arguments.length) + " for 0..1)"); } ; if ($truthy($$($nesting, 'Integer')['$==='](self))) { return $$($nesting, 'Rational').$new(self, 1) } else if ($truthy(self['$infinite?']())) { return self.$raise($$($nesting, 'FloatDomainError'), "Infinity") } else if ($truthy(self['$nan?']())) { return self.$raise($$($nesting, 'FloatDomainError'), "NaN") } else if ($truthy(eps == null)) { $b = $$($nesting, 'Math').$frexp(self), $a = Opal.to_ary($b), (f = ($a[0] == null ? nil : $a[0])), (n = ($a[1] == null ? nil : $a[1])), $b; f = $$($nesting, 'Math').$ldexp(f, $$$($$($nesting, 'Float'), 'MANT_DIG')).$to_i(); n = $rb_minus(n, $$$($$($nesting, 'Float'), 'MANT_DIG')); return $$($nesting, 'Rational').$new($rb_times(2, f), (1)['$<<']($rb_minus(1, n))).$rationalize($$($nesting, 'Rational').$new(1, (1)['$<<']($rb_minus(1, n)))); } else { return self.$to_r().$rationalize(eps) }; }, $Number_rationalize$55.$$arity = -1); Opal.def(self, '$remainder', $Number_remainder$56 = function $$remainder(y) { var self = this; return $rb_minus(self, $rb_times(y, $rb_divide(self, y).$truncate())) }, $Number_remainder$56.$$arity = 1); Opal.def(self, '$round', $Number_round$57 = function $$round(ndigits) { var $a, $b, self = this, _ = nil, exp = nil; ; if ($truthy($$($nesting, 'Integer')['$==='](self))) { if ($truthy(ndigits == null)) { return self}; if ($truthy(($truthy($a = $$($nesting, 'Float')['$==='](ndigits)) ? ndigits['$infinite?']() : $a))) { self.$raise($$($nesting, 'RangeError'), "Infinity")}; ndigits = $$($nesting, 'Opal')['$coerce_to!'](ndigits, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_lt(ndigits, $$$($$($nesting, 'Integer'), 'MIN')))) { self.$raise($$($nesting, 'RangeError'), "out of bounds")}; if ($truthy(ndigits >= 0)) { return self}; ndigits = ndigits['$-@'](); if (0.415241 * ndigits - 0.125 > self.$size()) { return 0; } var f = Math.pow(10, ndigits), x = Math.floor((Math.abs(x) + f / 2) / f) * f; return self < 0 ? -x : x; ; } else { if ($truthy(($truthy($a = self['$nan?']()) ? ndigits == null : $a))) { self.$raise($$($nesting, 'FloatDomainError'), "NaN")}; ndigits = $$($nesting, 'Opal')['$coerce_to!'](ndigits || 0, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_le(ndigits, 0))) { if ($truthy(self['$nan?']())) { self.$raise($$($nesting, 'RangeError'), "NaN") } else if ($truthy(self['$infinite?']())) { self.$raise($$($nesting, 'FloatDomainError'), "Infinity")} } else if (ndigits['$=='](0)) { return Math.round(self) } else if ($truthy(($truthy($a = self['$nan?']()) ? $a : self['$infinite?']()))) { return self}; $b = $$($nesting, 'Math').$frexp(self), $a = Opal.to_ary($b), (_ = ($a[0] == null ? nil : $a[0])), (exp = ($a[1] == null ? nil : $a[1])), $b; if ($truthy($rb_ge(ndigits, $rb_minus($rb_plus($$$($$($nesting, 'Float'), 'DIG'), 2), (function() {if ($truthy($rb_gt(exp, 0))) { return $rb_divide(exp, 4) } else { return $rb_minus($rb_divide(exp, 3), 1) }; return nil; })())))) { return self}; if ($truthy($rb_lt(ndigits, (function() {if ($truthy($rb_gt(exp, 0))) { return $rb_plus($rb_divide(exp, 3), 1) } else { return $rb_divide(exp, 4) }; return nil; })()['$-@']()))) { return 0}; return Math.round(self * Math.pow(10, ndigits)) / Math.pow(10, ndigits);; }; }, $Number_round$57.$$arity = -1); Opal.def(self, '$step', $Number_step$58 = function $$step($a, $b, $c) { var $iter = $Number_step$58.$$p, block = $iter || nil, $post_args, $kwargs, limit, step, to, by, $$59, self = this, positional_args = nil, keyword_args = nil; if ($iter) $Number_step$58.$$p = null; if ($iter) $Number_step$58.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); $kwargs = Opal.extract_kwargs($post_args); if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; if ($post_args.length > 0) { limit = $post_args[0]; $post_args.splice(0, 1); }; if ($post_args.length > 0) { step = $post_args[0]; $post_args.splice(0, 1); }; to = $kwargs.$$smap["to"];; by = $kwargs.$$smap["by"];; if (limit !== undefined && to !== undefined) { self.$raise($$($nesting, 'ArgumentError'), "to is given twice") } if (step !== undefined && by !== undefined) { self.$raise($$($nesting, 'ArgumentError'), "step is given twice") } function validateParameters() { if (to !== undefined) { limit = to; } if (limit === undefined) { limit = nil; } if (step === nil) { self.$raise($$($nesting, 'TypeError'), "step must be numeric") } if (step === 0) { self.$raise($$($nesting, 'ArgumentError'), "step can't be 0") } if (by !== undefined) { step = by; } if (step === nil || step == null) { step = 1; } var sign = step['$<=>'](0); if (sign === nil) { self.$raise($$($nesting, 'ArgumentError'), "" + "0 can't be coerced into " + (step.$class())) } if (limit === nil || limit == null) { limit = sign > 0 ? $$$($$($nesting, 'Float'), 'INFINITY') : $$$($$($nesting, 'Float'), 'INFINITY')['$-@'](); } $$($nesting, 'Opal').$compare(self, limit) } function stepFloatSize() { if ((step > 0 && self > limit) || (step < 0 && self < limit)) { return 0; } else if (step === Infinity || step === -Infinity) { return 1; } else { var abs = Math.abs, floor = Math.floor, err = (abs(self) + abs(limit) + abs(limit - self)) / abs(step) * $$$($$($nesting, 'Float'), 'EPSILON'); if (err === Infinity || err === -Infinity) { return 0; } else { if (err > 0.5) { err = 0.5; } return floor((limit - self) / step + err) + 1 } } } function stepSize() { validateParameters(); if (step === 0) { return Infinity; } if (step % 1 !== 0) { return stepFloatSize(); } else if ((step > 0 && self > limit) || (step < 0 && self < limit)) { return 0; } else { var ceil = Math.ceil, abs = Math.abs, lhs = abs(self - limit) + 1, rhs = abs(step); return ceil(lhs / rhs); } } ; if ((block !== nil)) { } else { positional_args = []; keyword_args = $hash2([], {}); if (limit !== undefined) { positional_args.push(limit); } if (step !== undefined) { positional_args.push(step); } if (to !== undefined) { Opal.hash_put(keyword_args, "to", to); } if (by !== undefined) { Opal.hash_put(keyword_args, "by", by); } if (keyword_args['$any?']()) { positional_args.push(keyword_args); } ; return $send(self, 'enum_for', ["step"].concat(Opal.to_a(positional_args)), ($$59 = function(){var self = $$59.$$s || this; return stepSize();}, $$59.$$s = self, $$59.$$arity = 0, $$59)); }; validateParameters(); if (step === 0) { while (true) { block(self); } } if (self % 1 !== 0 || limit % 1 !== 0 || step % 1 !== 0) { var n = stepFloatSize(); if (n > 0) { if (step === Infinity || step === -Infinity) { block(self); } else { var i = 0, d; if (step > 0) { while (i < n) { d = i * step + self; if (limit < d) { d = limit; } block(d); i += 1; } } else { while (i < n) { d = i * step + self; if (limit > d) { d = limit; } block(d); i += 1 } } } } } else { var value = self; if (step > 0) { while (value <= limit) { block(value); value += step; } } else { while (value >= limit) { block(value); value += step } } } return self; ; }, $Number_step$58.$$arity = -1); Opal.alias(self, "succ", "next"); Opal.def(self, '$times', $Number_times$60 = function $$times() { var $iter = $Number_times$60.$$p, block = $iter || nil, $$61, self = this; if ($iter) $Number_times$60.$$p = null; if ($iter) $Number_times$60.$$p = null;; if ($truthy(block)) { } else { return $send(self, 'enum_for', ["times"], ($$61 = function(){var self = $$61.$$s || this; return self}, $$61.$$s = self, $$61.$$arity = 0, $$61)) }; for (var i = 0; i < self; i++) { block(i); } ; return self; }, $Number_times$60.$$arity = 0); Opal.def(self, '$to_f', $Number_to_f$62 = function $$to_f() { var self = this; return self }, $Number_to_f$62.$$arity = 0); Opal.def(self, '$to_i', $Number_to_i$63 = function $$to_i() { var self = this; return parseInt(self, 10); }, $Number_to_i$63.$$arity = 0); Opal.alias(self, "to_int", "to_i"); Opal.def(self, '$to_r', $Number_to_r$64 = function $$to_r() { var $a, $b, self = this, f = nil, e = nil; if ($truthy($$($nesting, 'Integer')['$==='](self))) { return $$($nesting, 'Rational').$new(self, 1) } else { $b = $$($nesting, 'Math').$frexp(self), $a = Opal.to_ary($b), (f = ($a[0] == null ? nil : $a[0])), (e = ($a[1] == null ? nil : $a[1])), $b; f = $$($nesting, 'Math').$ldexp(f, $$$($$($nesting, 'Float'), 'MANT_DIG')).$to_i(); e = $rb_minus(e, $$$($$($nesting, 'Float'), 'MANT_DIG')); return $rb_times(f, $$$($$($nesting, 'Float'), 'RADIX')['$**'](e)).$to_r(); } }, $Number_to_r$64.$$arity = 0); Opal.def(self, '$to_s', $Number_to_s$65 = function $$to_s(base) { var $a, self = this; if (base == null) { base = 10; }; base = $$($nesting, 'Opal')['$coerce_to!'](base, $$($nesting, 'Integer'), "to_int"); if ($truthy(($truthy($a = $rb_lt(base, 2)) ? $a : $rb_gt(base, 36)))) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid radix " + (base))}; return self.toString(base);; }, $Number_to_s$65.$$arity = -1); Opal.def(self, '$truncate', $Number_truncate$66 = function $$truncate(ndigits) { var self = this; if (ndigits == null) { ndigits = 0; }; var f = self.$to_f(); if (f % 1 === 0 && ndigits >= 0) { return f; } var factor = Math.pow(10, ndigits), result = parseInt(f * factor, 10) / factor; if (f % 1 === 0) { result = Math.round(result); } return result; ; }, $Number_truncate$66.$$arity = -1); Opal.alias(self, "inspect", "to_s"); Opal.def(self, '$digits', $Number_digits$67 = function $$digits(base) { var self = this; if (base == null) { base = 10; }; if ($rb_lt(self, 0)) { self.$raise($$$($$($nesting, 'Math'), 'DomainError'), "out of domain")}; base = $$($nesting, 'Opal')['$coerce_to!'](base, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_lt(base, 2))) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid radix " + (base))}; var value = self, result = []; while (value !== 0) { result.push(value % base); value = parseInt(value / base, 10); } return result; ; }, $Number_digits$67.$$arity = -1); Opal.def(self, '$divmod', $Number_divmod$68 = function $$divmod(other) { var $a, $iter = $Number_divmod$68.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Number_divmod$68.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($truthy(($truthy($a = self['$nan?']()) ? $a : other['$nan?']()))) { return self.$raise($$($nesting, 'FloatDomainError'), "NaN") } else if ($truthy(self['$infinite?']())) { return self.$raise($$($nesting, 'FloatDomainError'), "Infinity") } else { return $send(self, Opal.find_super_dispatcher(self, 'divmod', $Number_divmod$68, false), $zuper, $iter) } }, $Number_divmod$68.$$arity = 1); Opal.def(self, '$upto', $Number_upto$69 = function $$upto(stop) { var $iter = $Number_upto$69.$$p, block = $iter || nil, $$70, self = this; if ($iter) $Number_upto$69.$$p = null; if ($iter) $Number_upto$69.$$p = null;; if ((block !== nil)) { } else { return $send(self, 'enum_for', ["upto", stop], ($$70 = function(){var self = $$70.$$s || this; if ($truthy($$($nesting, 'Numeric')['$==='](stop))) { } else { self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") }; if ($truthy($rb_lt(stop, self))) { return 0 } else { return $rb_plus($rb_minus(stop, self), 1) };}, $$70.$$s = self, $$70.$$arity = 0, $$70)) }; if (!stop.$$is_number) { self.$raise($$($nesting, 'ArgumentError'), "" + "comparison of " + (self.$class()) + " with " + (stop.$class()) + " failed") } for (var i = self; i <= stop; i++) { block(i); } ; return self; }, $Number_upto$69.$$arity = 1); Opal.def(self, '$zero?', $Number_zero$ques$71 = function() { var self = this; return self == 0; }, $Number_zero$ques$71.$$arity = 0); Opal.def(self, '$size', $Number_size$72 = function $$size() { var self = this; return 4 }, $Number_size$72.$$arity = 0); Opal.def(self, '$nan?', $Number_nan$ques$73 = function() { var self = this; return isNaN(self); }, $Number_nan$ques$73.$$arity = 0); Opal.def(self, '$finite?', $Number_finite$ques$74 = function() { var self = this; return self != Infinity && self != -Infinity && !isNaN(self); }, $Number_finite$ques$74.$$arity = 0); Opal.def(self, '$infinite?', $Number_infinite$ques$75 = function() { var self = this; if (self == Infinity) { return +1; } else if (self == -Infinity) { return -1; } else { return nil; } }, $Number_infinite$ques$75.$$arity = 0); Opal.def(self, '$positive?', $Number_positive$ques$76 = function() { var self = this; return self != 0 && (self == Infinity || 1 / self > 0); }, $Number_positive$ques$76.$$arity = 0); return (Opal.def(self, '$negative?', $Number_negative$ques$77 = function() { var self = this; return self == -Infinity || 1 / self < 0; }, $Number_negative$ques$77.$$arity = 0), nil) && 'negative?'; })($nesting[0], $$($nesting, 'Numeric'), $nesting); Opal.const_set($nesting[0], 'Fixnum', $$($nesting, 'Number')); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Integer'); var $nesting = [self].concat($parent_nesting); self.$$is_number_class = true; (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $allocate$78, $eq_eq_eq$79, $sqrt$80; Opal.def(self, '$allocate', $allocate$78 = function $$allocate() { var self = this; return self.$raise($$($nesting, 'TypeError'), "" + "allocator undefined for " + (self.$name())) }, $allocate$78.$$arity = 0); Opal.udef(self, '$' + "new");; Opal.def(self, '$===', $eq_eq_eq$79 = function(other) { var self = this; if (!other.$$is_number) { return false; } return (other % 1) === 0; }, $eq_eq_eq$79.$$arity = 1); return (Opal.def(self, '$sqrt', $sqrt$80 = function $$sqrt(n) { var self = this; n = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); if (n < 0) { self.$raise($$$($$($nesting, 'Math'), 'DomainError'), "Numerical argument is out of domain - \"isqrt\"") } return parseInt(Math.sqrt(n), 10); ; }, $sqrt$80.$$arity = 1), nil) && 'sqrt'; })(Opal.get_singleton_class(self), $nesting); Opal.const_set($nesting[0], 'MAX', Math.pow(2, 30) - 1); return Opal.const_set($nesting[0], 'MIN', -Math.pow(2, 30)); })($nesting[0], $$($nesting, 'Numeric'), $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Float'); var $nesting = [self].concat($parent_nesting); self.$$is_number_class = true; (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $allocate$81, $eq_eq_eq$82; Opal.def(self, '$allocate', $allocate$81 = function $$allocate() { var self = this; return self.$raise($$($nesting, 'TypeError'), "" + "allocator undefined for " + (self.$name())) }, $allocate$81.$$arity = 0); Opal.udef(self, '$' + "new");; return (Opal.def(self, '$===', $eq_eq_eq$82 = function(other) { var self = this; return !!other.$$is_number; }, $eq_eq_eq$82.$$arity = 1), nil) && '==='; })(Opal.get_singleton_class(self), $nesting); Opal.const_set($nesting[0], 'INFINITY', Infinity); Opal.const_set($nesting[0], 'MAX', Number.MAX_VALUE); Opal.const_set($nesting[0], 'MIN', Number.MIN_VALUE); Opal.const_set($nesting[0], 'NAN', NaN); Opal.const_set($nesting[0], 'DIG', 15); Opal.const_set($nesting[0], 'MANT_DIG', 53); Opal.const_set($nesting[0], 'RADIX', 2); return Opal.const_set($nesting[0], 'EPSILON', Number.EPSILON || 2.2204460492503130808472633361816E-16); })($nesting[0], $$($nesting, 'Numeric'), $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/range"] = function(Opal) { function $rb_le(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_ge(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$require', '$include', '$attr_reader', '$raise', '$<=>', '$include?', '$<=', '$<', '$enum_for', '$upto', '$to_proc', '$respond_to?', '$class', '$succ', '$!', '$==', '$===', '$exclude_end?', '$eql?', '$begin', '$end', '$last', '$to_a', '$>', '$-', '$abs', '$to_i', '$coerce_to!', '$ceil', '$/', '$size', '$loop', '$+', '$*', '$>=', '$each_with_index', '$%', '$bsearch', '$inspect', '$[]', '$hash']); self.$require("corelib/enumerable"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Range'); var $nesting = [self].concat($parent_nesting), $Range_initialize$1, $Range_$eq_eq$2, $Range_$eq_eq_eq$3, $Range_cover$ques$4, $Range_each$5, $Range_eql$ques$6, $Range_exclude_end$ques$7, $Range_first$8, $Range_last$9, $Range_max$10, $Range_min$11, $Range_size$12, $Range_step$13, $Range_bsearch$17, $Range_to_s$18, $Range_inspect$19, $Range_marshal_load$20, $Range_hash$21; self.$$prototype.begin = self.$$prototype.end = self.$$prototype.excl = nil; self.$include($$($nesting, 'Enumerable')); self.$$prototype.$$is_range = true; self.$attr_reader("begin", "end"); Opal.def(self, '$initialize', $Range_initialize$1 = function $$initialize(first, last, exclude) { var self = this; if (exclude == null) { exclude = false; }; if ($truthy(self.begin)) { self.$raise($$($nesting, 'NameError'), "'initialize' called twice")}; if ($truthy(first['$<=>'](last))) { } else { self.$raise($$($nesting, 'ArgumentError'), "bad value for range") }; self.begin = first; self.end = last; return (self.excl = exclude); }, $Range_initialize$1.$$arity = -3); Opal.def(self, '$==', $Range_$eq_eq$2 = function(other) { var self = this; if (!other.$$is_range) { return false; } return self.excl === other.excl && self.begin == other.begin && self.end == other.end; }, $Range_$eq_eq$2.$$arity = 1); Opal.def(self, '$===', $Range_$eq_eq_eq$3 = function(value) { var self = this; return self['$include?'](value) }, $Range_$eq_eq_eq$3.$$arity = 1); Opal.def(self, '$cover?', $Range_cover$ques$4 = function(value) { var $a, self = this, beg_cmp = nil, end_cmp = nil; beg_cmp = self.begin['$<=>'](value); if ($truthy(($truthy($a = beg_cmp) ? $rb_le(beg_cmp, 0) : $a))) { } else { return false }; end_cmp = value['$<=>'](self.end); if ($truthy(self.excl)) { return ($truthy($a = end_cmp) ? $rb_lt(end_cmp, 0) : $a) } else { return ($truthy($a = end_cmp) ? $rb_le(end_cmp, 0) : $a) }; }, $Range_cover$ques$4.$$arity = 1); Opal.def(self, '$each', $Range_each$5 = function $$each() { var $iter = $Range_each$5.$$p, block = $iter || nil, $a, self = this, current = nil, last = nil; if ($iter) $Range_each$5.$$p = null; if ($iter) $Range_each$5.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("each") }; var i, limit; if (self.begin.$$is_number && self.end.$$is_number) { if (self.begin % 1 !== 0 || self.end % 1 !== 0) { self.$raise($$($nesting, 'TypeError'), "can't iterate from Float") } for (i = self.begin, limit = self.end + (function() {if ($truthy(self.excl)) { return 0 } else { return 1 }; return nil; })(); i < limit; i++) { block(i); } return self; } if (self.begin.$$is_string && self.end.$$is_string) { $send(self.begin, 'upto', [self.end, self.excl], block.$to_proc()) return self; } ; current = self.begin; last = self.end; if ($truthy(current['$respond_to?']("succ"))) { } else { self.$raise($$($nesting, 'TypeError'), "" + "can't iterate from " + (current.$class())) }; while ($truthy($rb_lt(current['$<=>'](last), 0))) { Opal.yield1(block, current); current = current.$succ(); }; if ($truthy(($truthy($a = self.excl['$!']()) ? current['$=='](last) : $a))) { Opal.yield1(block, current)}; return self; }, $Range_each$5.$$arity = 0); Opal.def(self, '$eql?', $Range_eql$ques$6 = function(other) { var $a, $b, self = this; if ($truthy($$($nesting, 'Range')['$==='](other))) { } else { return false }; return ($truthy($a = ($truthy($b = self.excl['$==='](other['$exclude_end?']())) ? self.begin['$eql?'](other.$begin()) : $b)) ? self.end['$eql?'](other.$end()) : $a); }, $Range_eql$ques$6.$$arity = 1); Opal.def(self, '$exclude_end?', $Range_exclude_end$ques$7 = function() { var self = this; return self.excl }, $Range_exclude_end$ques$7.$$arity = 0); Opal.def(self, '$first', $Range_first$8 = function $$first(n) { var $iter = $Range_first$8.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Range_first$8.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } ; if ($truthy(n == null)) { return self.begin}; return $send(self, Opal.find_super_dispatcher(self, 'first', $Range_first$8, false), $zuper, $iter); }, $Range_first$8.$$arity = -1); Opal.alias(self, "include?", "cover?"); Opal.def(self, '$last', $Range_last$9 = function $$last(n) { var self = this; ; if ($truthy(n == null)) { return self.end}; return self.$to_a().$last(n); }, $Range_last$9.$$arity = -1); Opal.def(self, '$max', $Range_max$10 = function $$max() { var $a, $iter = $Range_max$10.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Range_max$10.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if (($yield !== nil)) { return $send(self, Opal.find_super_dispatcher(self, 'max', $Range_max$10, false), $zuper, $iter) } else if ($truthy($rb_gt(self.begin, self.end))) { return nil } else if ($truthy(($truthy($a = self.excl) ? self.begin['$=='](self.end) : $a))) { return nil } else { return self.excl ? self.end - 1 : self.end } }, $Range_max$10.$$arity = 0); Opal.alias(self, "member?", "cover?"); Opal.def(self, '$min', $Range_min$11 = function $$min() { var $a, $iter = $Range_min$11.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Range_min$11.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if (($yield !== nil)) { return $send(self, Opal.find_super_dispatcher(self, 'min', $Range_min$11, false), $zuper, $iter) } else if ($truthy($rb_gt(self.begin, self.end))) { return nil } else if ($truthy(($truthy($a = self.excl) ? self.begin['$=='](self.end) : $a))) { return nil } else { return self.begin } }, $Range_min$11.$$arity = 0); Opal.def(self, '$size', $Range_size$12 = function $$size() { var $a, self = this, range_begin = nil, range_end = nil, infinity = nil; range_begin = self.begin; range_end = self.end; if ($truthy(self.excl)) { range_end = $rb_minus(range_end, 1)}; if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](range_begin)) ? $$($nesting, 'Numeric')['$==='](range_end) : $a))) { } else { return nil }; if ($truthy($rb_lt(range_end, range_begin))) { return 0}; infinity = $$$($$($nesting, 'Float'), 'INFINITY'); if ($truthy([range_begin.$abs(), range_end.$abs()]['$include?'](infinity))) { return infinity}; return (Math.abs(range_end - range_begin) + 1).$to_i(); }, $Range_size$12.$$arity = 0); Opal.def(self, '$step', $Range_step$13 = function $$step(n) { var $$14, $$15, $$16, $iter = $Range_step$13.$$p, $yield = $iter || nil, self = this, i = nil; if ($iter) $Range_step$13.$$p = null; if (n == null) { n = 1; }; function coerceStepSize() { if (!n.$$is_number) { n = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int") } if (n < 0) { self.$raise($$($nesting, 'ArgumentError'), "step can't be negative") } else if (n === 0) { self.$raise($$($nesting, 'ArgumentError'), "step can't be 0") } } function enumeratorSize() { if (!self.begin['$respond_to?']("succ")) { return nil; } if (self.begin.$$is_string && self.end.$$is_string) { return nil; } if (n % 1 === 0) { return $rb_divide(self.$size(), n).$ceil(); } else { // n is a float var begin = self.begin, end = self.end, abs = Math.abs, floor = Math.floor, err = (abs(begin) + abs(end) + abs(end - begin)) / abs(n) * $$$($$($nesting, 'Float'), 'EPSILON'), size; if (err > 0.5) { err = 0.5; } if (self.excl) { size = floor((end - begin) / n - err); if (size * n + begin < end) { size++; } } else { size = floor((end - begin) / n + err) + 1 } return size; } } ; if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["step", n], ($$14 = function(){var self = $$14.$$s || this; coerceStepSize(); return enumeratorSize(); }, $$14.$$s = self, $$14.$$arity = 0, $$14)) }; coerceStepSize(); if ($truthy(self.begin.$$is_number && self.end.$$is_number)) { i = 0; (function(){var $brk = Opal.new_brk(); try {return $send(self, 'loop', [], ($$15 = function(){var self = $$15.$$s || this, current = nil; if (self.begin == null) self.begin = nil; if (self.excl == null) self.excl = nil; if (self.end == null) self.end = nil; current = $rb_plus(self.begin, $rb_times(i, n)); if ($truthy(self.excl)) { if ($truthy($rb_ge(current, self.end))) { Opal.brk(nil, $brk)} } else if ($truthy($rb_gt(current, self.end))) { Opal.brk(nil, $brk)}; Opal.yield1($yield, current); return (i = $rb_plus(i, 1));}, $$15.$$s = self, $$15.$$brk = $brk, $$15.$$arity = 0, $$15)) } catch (err) { if (err === $brk) { return err.$v } else { throw err } }})(); } else { if (self.begin.$$is_string && self.end.$$is_string && n % 1 !== 0) { self.$raise($$($nesting, 'TypeError'), "no implicit conversion to float from string") } ; $send(self, 'each_with_index', [], ($$16 = function(value, idx){var self = $$16.$$s || this; if (value == null) { value = nil; }; if (idx == null) { idx = nil; }; if (idx['$%'](n)['$=='](0)) { return Opal.yield1($yield, value); } else { return nil };}, $$16.$$s = self, $$16.$$arity = 2, $$16)); }; return self; }, $Range_step$13.$$arity = -1); Opal.def(self, '$bsearch', $Range_bsearch$17 = function $$bsearch() { var $iter = $Range_bsearch$17.$$p, block = $iter || nil, self = this; if ($iter) $Range_bsearch$17.$$p = null; if ($iter) $Range_bsearch$17.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("bsearch") }; if ($truthy(self.begin.$$is_number && self.end.$$is_number)) { } else { self.$raise($$($nesting, 'TypeError'), "" + "can't do binary search for " + (self.begin.$class())) }; return $send(self.$to_a(), 'bsearch', [], block.$to_proc()); }, $Range_bsearch$17.$$arity = 0); Opal.def(self, '$to_s', $Range_to_s$18 = function $$to_s() { var self = this; return "" + (self.begin) + ((function() {if ($truthy(self.excl)) { return "..." } else { return ".." }; return nil; })()) + (self.end) }, $Range_to_s$18.$$arity = 0); Opal.def(self, '$inspect', $Range_inspect$19 = function $$inspect() { var self = this; return "" + (self.begin.$inspect()) + ((function() {if ($truthy(self.excl)) { return "..." } else { return ".." }; return nil; })()) + (self.end.$inspect()) }, $Range_inspect$19.$$arity = 0); Opal.def(self, '$marshal_load', $Range_marshal_load$20 = function $$marshal_load(args) { var self = this; self.begin = args['$[]']("begin"); self.end = args['$[]']("end"); return (self.excl = args['$[]']("excl")); }, $Range_marshal_load$20.$$arity = 1); return (Opal.def(self, '$hash', $Range_hash$21 = function $$hash() { var self = this; return [self.begin, self.end, self.excl].$hash() }, $Range_hash$21.$$arity = 0), nil) && 'hash'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/proc"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$raise', '$coerce_to!']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Proc'); var $nesting = [self].concat($parent_nesting), $Proc_new$1, $Proc_call$2, $Proc_to_proc$3, $Proc_lambda$ques$4, $Proc_arity$5, $Proc_source_location$6, $Proc_binding$7, $Proc_parameters$8, $Proc_curry$9, $Proc_dup$10; Opal.defineProperty(self.$$prototype, '$$is_proc', true); Opal.defineProperty(self.$$prototype, '$$is_lambda', false); Opal.defs(self, '$new', $Proc_new$1 = function() { var $iter = $Proc_new$1.$$p, block = $iter || nil, self = this; if ($iter) $Proc_new$1.$$p = null; if ($iter) $Proc_new$1.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "tried to create a Proc object without a block") }; return block; }, $Proc_new$1.$$arity = 0); Opal.def(self, '$call', $Proc_call$2 = function $$call($a) { var $iter = $Proc_call$2.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Proc_call$2.$$p = null; if ($iter) $Proc_call$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if (block !== nil) { self.$$p = block; } var result, $brk = self.$$brk; if ($brk) { try { if (self.$$is_lambda) { result = self.apply(null, args); } else { result = Opal.yieldX(self, args); } } catch (err) { if (err === $brk) { return $brk.$v } else { throw err } } } else { if (self.$$is_lambda) { result = self.apply(null, args); } else { result = Opal.yieldX(self, args); } } return result; ; }, $Proc_call$2.$$arity = -1); Opal.alias(self, "[]", "call"); Opal.alias(self, "===", "call"); Opal.alias(self, "yield", "call"); Opal.def(self, '$to_proc', $Proc_to_proc$3 = function $$to_proc() { var self = this; return self }, $Proc_to_proc$3.$$arity = 0); Opal.def(self, '$lambda?', $Proc_lambda$ques$4 = function() { var self = this; return !!self.$$is_lambda; }, $Proc_lambda$ques$4.$$arity = 0); Opal.def(self, '$arity', $Proc_arity$5 = function $$arity() { var self = this; if (self.$$is_curried) { return -1; } else { return self.$$arity; } }, $Proc_arity$5.$$arity = 0); Opal.def(self, '$source_location', $Proc_source_location$6 = function $$source_location() { var self = this; if (self.$$is_curried) { return nil; }; return nil; }, $Proc_source_location$6.$$arity = 0); Opal.def(self, '$binding', $Proc_binding$7 = function $$binding() { var self = this; if (self.$$is_curried) { self.$raise($$($nesting, 'ArgumentError'), "Can't create Binding") }; return nil; }, $Proc_binding$7.$$arity = 0); Opal.def(self, '$parameters', $Proc_parameters$8 = function $$parameters() { var self = this; if (self.$$is_curried) { return [["rest"]]; } else if (self.$$parameters) { if (self.$$is_lambda) { return self.$$parameters; } else { var result = [], i, length; for (i = 0, length = self.$$parameters.length; i < length; i++) { var parameter = self.$$parameters[i]; if (parameter[0] === 'req') { // required arguments always have name parameter = ['opt', parameter[1]]; } result.push(parameter); } return result; } } else { return []; } }, $Proc_parameters$8.$$arity = 0); Opal.def(self, '$curry', $Proc_curry$9 = function $$curry(arity) { var self = this; ; if (arity === undefined) { arity = self.length; } else { arity = $$($nesting, 'Opal')['$coerce_to!'](arity, $$($nesting, 'Integer'), "to_int"); if (self.$$is_lambda && arity !== self.length) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arity) + " for " + (self.length) + ")") } } function curried () { var args = $slice.call(arguments), length = args.length, result; if (length > arity && self.$$is_lambda && !self.$$is_curried) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (length) + " for " + (arity) + ")") } if (length >= arity) { return self.$call.apply(self, args); } result = function () { return curried.apply(null, args.concat($slice.call(arguments))); } result.$$is_lambda = self.$$is_lambda; result.$$is_curried = true; return result; }; curried.$$is_lambda = self.$$is_lambda; curried.$$is_curried = true; return curried; ; }, $Proc_curry$9.$$arity = -1); Opal.def(self, '$dup', $Proc_dup$10 = function $$dup() { var self = this; var original_proc = self.$$original_proc || self, proc = function () { return original_proc.apply(this, arguments); }; for (var prop in self) { if (self.hasOwnProperty(prop)) { proc[prop] = self[prop]; } } return proc; }, $Proc_dup$10.$$arity = 0); return Opal.alias(self, "clone", "dup"); })($nesting[0], Function, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/method"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$attr_reader', '$arity', '$new', '$class', '$join', '$source_location', '$raise']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Method'); var $nesting = [self].concat($parent_nesting), $Method_initialize$1, $Method_arity$2, $Method_parameters$3, $Method_source_location$4, $Method_comments$5, $Method_call$6, $Method_unbind$7, $Method_to_proc$8, $Method_inspect$9; self.$$prototype.method = self.$$prototype.receiver = self.$$prototype.owner = self.$$prototype.name = nil; self.$attr_reader("owner", "receiver", "name"); Opal.def(self, '$initialize', $Method_initialize$1 = function $$initialize(receiver, owner, method, name) { var self = this; self.receiver = receiver; self.owner = owner; self.name = name; return (self.method = method); }, $Method_initialize$1.$$arity = 4); Opal.def(self, '$arity', $Method_arity$2 = function $$arity() { var self = this; return self.method.$arity() }, $Method_arity$2.$$arity = 0); Opal.def(self, '$parameters', $Method_parameters$3 = function $$parameters() { var self = this; return self.method.$$parameters }, $Method_parameters$3.$$arity = 0); Opal.def(self, '$source_location', $Method_source_location$4 = function $$source_location() { var $a, self = this; return ($truthy($a = self.method.$$source_location) ? $a : ["(eval)", 0]) }, $Method_source_location$4.$$arity = 0); Opal.def(self, '$comments', $Method_comments$5 = function $$comments() { var $a, self = this; return ($truthy($a = self.method.$$comments) ? $a : []) }, $Method_comments$5.$$arity = 0); Opal.def(self, '$call', $Method_call$6 = function $$call($a) { var $iter = $Method_call$6.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Method_call$6.$$p = null; if ($iter) $Method_call$6.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; self.method.$$p = block; return self.method.apply(self.receiver, args); ; }, $Method_call$6.$$arity = -1); Opal.alias(self, "[]", "call"); Opal.def(self, '$unbind', $Method_unbind$7 = function $$unbind() { var self = this; return $$($nesting, 'UnboundMethod').$new(self.receiver.$class(), self.owner, self.method, self.name) }, $Method_unbind$7.$$arity = 0); Opal.def(self, '$to_proc', $Method_to_proc$8 = function $$to_proc() { var self = this; var proc = self.$call.bind(self); proc.$$unbound = self.method; proc.$$is_lambda = true; proc.$$arity = self.method.$$arity; proc.$$parameters = self.method.$$parameters; return proc; }, $Method_to_proc$8.$$arity = 0); return (Opal.def(self, '$inspect', $Method_inspect$9 = function $$inspect() { var self = this; return "" + "#<" + (self.$class()) + ": " + (self.receiver.$class()) + "#" + (self.name) + " (defined in " + (self.owner) + " in " + (self.$source_location().$join(":")) + ")>" }, $Method_inspect$9.$$arity = 0), nil) && 'inspect'; })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'UnboundMethod'); var $nesting = [self].concat($parent_nesting), $UnboundMethod_initialize$10, $UnboundMethod_arity$11, $UnboundMethod_parameters$12, $UnboundMethod_source_location$13, $UnboundMethod_comments$14, $UnboundMethod_bind$15, $UnboundMethod_inspect$16; self.$$prototype.method = self.$$prototype.owner = self.$$prototype.name = self.$$prototype.source = nil; self.$attr_reader("source", "owner", "name"); Opal.def(self, '$initialize', $UnboundMethod_initialize$10 = function $$initialize(source, owner, method, name) { var self = this; self.source = source; self.owner = owner; self.method = method; return (self.name = name); }, $UnboundMethod_initialize$10.$$arity = 4); Opal.def(self, '$arity', $UnboundMethod_arity$11 = function $$arity() { var self = this; return self.method.$arity() }, $UnboundMethod_arity$11.$$arity = 0); Opal.def(self, '$parameters', $UnboundMethod_parameters$12 = function $$parameters() { var self = this; return self.method.$$parameters }, $UnboundMethod_parameters$12.$$arity = 0); Opal.def(self, '$source_location', $UnboundMethod_source_location$13 = function $$source_location() { var $a, self = this; return ($truthy($a = self.method.$$source_location) ? $a : ["(eval)", 0]) }, $UnboundMethod_source_location$13.$$arity = 0); Opal.def(self, '$comments', $UnboundMethod_comments$14 = function $$comments() { var $a, self = this; return ($truthy($a = self.method.$$comments) ? $a : []) }, $UnboundMethod_comments$14.$$arity = 0); Opal.def(self, '$bind', $UnboundMethod_bind$15 = function $$bind(object) { var self = this; if (self.owner.$$is_module || Opal.is_a(object, self.owner)) { return $$($nesting, 'Method').$new(object, self.owner, self.method, self.name); } else { self.$raise($$($nesting, 'TypeError'), "" + "can't bind singleton method to a different class (expected " + (object) + ".kind_of?(" + (self.owner) + " to be true)"); } }, $UnboundMethod_bind$15.$$arity = 1); return (Opal.def(self, '$inspect', $UnboundMethod_inspect$16 = function $$inspect() { var self = this; return "" + "#<" + (self.$class()) + ": " + (self.source) + "#" + (self.name) + " (defined in " + (self.owner) + " in " + (self.$source_location().$join(":")) + ")>" }, $UnboundMethod_inspect$16.$$arity = 0), nil) && 'inspect'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/variables"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $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.const_set($nesting[0], 'ARGV', []); Opal.const_set($nesting[0], 'ARGF', $$($nesting, 'Object').$new()); Opal.const_set($nesting[0], 'ENV', $hash2([], {})); $gvars.VERBOSE = false; $gvars.DEBUG = false; return ($gvars.SAFE = 0); }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/regexp_anchors"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; Opal.add_stubs(['$==', '$new']); return (function($base, $parent_nesting) { var self = $module($base, 'Opal'); var $nesting = [self].concat($parent_nesting); Opal.const_set($nesting[0], 'REGEXP_START', (function() {if ($$($nesting, 'RUBY_ENGINE')['$==']("opal")) { return "^" } else { return nil }; return nil; })()); Opal.const_set($nesting[0], 'REGEXP_END', (function() {if ($$($nesting, 'RUBY_ENGINE')['$==']("opal")) { return "$" } else { return nil }; return nil; })()); Opal.const_set($nesting[0], 'FORBIDDEN_STARTING_IDENTIFIER_CHARS', "\\u0001-\\u002F\\u003A-\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"); Opal.const_set($nesting[0], 'FORBIDDEN_ENDING_IDENTIFIER_CHARS', "\\u0001-\\u0020\\u0022-\\u002F\\u003A-\\u003E\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"); Opal.const_set($nesting[0], 'INLINE_IDENTIFIER_REGEXP', $$($nesting, 'Regexp').$new("" + "[^" + ($$($nesting, 'FORBIDDEN_STARTING_IDENTIFIER_CHARS')) + "]*[^" + ($$($nesting, 'FORBIDDEN_ENDING_IDENTIFIER_CHARS')) + "]")); Opal.const_set($nesting[0], 'FORBIDDEN_CONST_NAME_CHARS', "\\u0001-\\u0020\\u0021-\\u002F\\u003B-\\u003F\\u0040\\u005B-\\u005E\\u0060\\u007B-\\u007F"); Opal.const_set($nesting[0], 'CONST_NAME_REGEXP', $$($nesting, 'Regexp').$new("" + ($$($nesting, 'REGEXP_START')) + "(::)?[A-Z][^" + ($$($nesting, 'FORBIDDEN_CONST_NAME_CHARS')) + "]*" + ($$($nesting, 'REGEXP_END')))); })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/mini"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$require']); self.$require("opal/base"); self.$require("corelib/nil"); self.$require("corelib/boolean"); self.$require("corelib/string"); self.$require("corelib/comparable"); self.$require("corelib/enumerable"); self.$require("corelib/enumerator"); self.$require("corelib/array"); self.$require("corelib/hash"); self.$require("corelib/number"); self.$require("corelib/range"); self.$require("corelib/proc"); self.$require("corelib/method"); self.$require("corelib/regexp"); self.$require("corelib/variables"); return self.$require("opal/regexp_anchors"); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/kernel/format"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy, $gvars = Opal.gvars; Opal.add_stubs(['$==', '$length', '$respond_to?', '$[]', '$coerce_to?', '$nil?', '$to_a', '$raise', '$to_int', '$fetch', '$Integer', '$Float', '$to_ary', '$to_str', '$coerce_to', '$inspect', '$to_s']); return (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_format$1; Opal.def(self, '$format', $Kernel_format$1 = function $$format(format_string, $a) { var $post_args, args, $b, self = this, ary = nil; if ($gvars.DEBUG == null) $gvars.DEBUG = nil; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy((($b = args.$length()['$=='](1)) ? args['$[]'](0)['$respond_to?']("to_ary") : args.$length()['$=='](1)))) { ary = $$($nesting, 'Opal')['$coerce_to?'](args['$[]'](0), $$($nesting, 'Array'), "to_ary"); if ($truthy(ary['$nil?']())) { } else { args = ary.$to_a() };}; var result = '', //used for slicing: begin_slice = 0, end_slice, //used for iterating over the format string: i, len = format_string.length, //used for processing field values: arg, str, //used for processing %g and %G fields: exponent, //used for keeping track of width and precision: width, precision, //used for holding temporary values: tmp_num, //used for processing %{} and %<> fileds: hash_parameter_key, closing_brace_char, //used for processing %b, %B, %o, %x, and %X fields: base_number, base_prefix, base_neg_zero_regex, base_neg_zero_digit, //used for processing arguments: next_arg, seq_arg_num = 1, pos_arg_num = 0, //used for keeping track of flags: flags, FNONE = 0, FSHARP = 1, FMINUS = 2, FPLUS = 4, FZERO = 8, FSPACE = 16, FWIDTH = 32, FPREC = 64, FPREC0 = 128; function CHECK_FOR_FLAGS() { if (flags&FWIDTH) { self.$raise($$($nesting, 'ArgumentError'), "flag after width") } if (flags&FPREC0) { self.$raise($$($nesting, 'ArgumentError'), "flag after precision") } } function CHECK_FOR_WIDTH() { if (flags&FWIDTH) { self.$raise($$($nesting, 'ArgumentError'), "width given twice") } if (flags&FPREC0) { self.$raise($$($nesting, 'ArgumentError'), "width after precision") } } function GET_NTH_ARG(num) { if (num >= args.length) { self.$raise($$($nesting, 'ArgumentError'), "too few arguments") } return args[num]; } function GET_NEXT_ARG() { switch (pos_arg_num) { case -1: self.$raise($$($nesting, 'ArgumentError'), "" + "unnumbered(" + (seq_arg_num) + ") mixed with numbered") case -2: self.$raise($$($nesting, 'ArgumentError'), "" + "unnumbered(" + (seq_arg_num) + ") mixed with named") } pos_arg_num = seq_arg_num++; return GET_NTH_ARG(pos_arg_num - 1); } function GET_POS_ARG(num) { if (pos_arg_num > 0) { self.$raise($$($nesting, 'ArgumentError'), "" + "numbered(" + (num) + ") after unnumbered(" + (pos_arg_num) + ")") } if (pos_arg_num === -2) { self.$raise($$($nesting, 'ArgumentError'), "" + "numbered(" + (num) + ") after named") } if (num < 1) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid index - " + (num) + "$") } pos_arg_num = -1; return GET_NTH_ARG(num - 1); } function GET_ARG() { return (next_arg === undefined ? GET_NEXT_ARG() : next_arg); } function READ_NUM(label) { var num, str = ''; for (;; i++) { if (i === len) { self.$raise($$($nesting, 'ArgumentError'), "malformed format string - %*[0-9]") } if (format_string.charCodeAt(i) < 48 || format_string.charCodeAt(i) > 57) { i--; num = parseInt(str, 10) || 0; if (num > 2147483647) { self.$raise($$($nesting, 'ArgumentError'), "" + (label) + " too big") } return num; } str += format_string.charAt(i); } } function READ_NUM_AFTER_ASTER(label) { var arg, num = READ_NUM(label); if (format_string.charAt(i + 1) === '$') { i++; arg = GET_POS_ARG(num); } else { arg = GET_NEXT_ARG(); } return (arg).$to_int(); } for (i = format_string.indexOf('%'); i !== -1; i = format_string.indexOf('%', i)) { str = undefined; flags = FNONE; width = -1; precision = -1; next_arg = undefined; end_slice = i; i++; switch (format_string.charAt(i)) { case '%': begin_slice = i; case '': case '\n': case '\0': i++; continue; } format_sequence: for (; i < len; i++) { switch (format_string.charAt(i)) { case ' ': CHECK_FOR_FLAGS(); flags |= FSPACE; continue format_sequence; case '#': CHECK_FOR_FLAGS(); flags |= FSHARP; continue format_sequence; case '+': CHECK_FOR_FLAGS(); flags |= FPLUS; continue format_sequence; case '-': CHECK_FOR_FLAGS(); flags |= FMINUS; continue format_sequence; case '0': CHECK_FOR_FLAGS(); flags |= FZERO; continue format_sequence; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': tmp_num = READ_NUM('width'); if (format_string.charAt(i + 1) === '$') { if (i + 2 === len) { str = '%'; i++; break format_sequence; } if (next_arg !== undefined) { self.$raise($$($nesting, 'ArgumentError'), "" + "value given twice - %" + (tmp_num) + "$") } next_arg = GET_POS_ARG(tmp_num); i++; } else { CHECK_FOR_WIDTH(); flags |= FWIDTH; width = tmp_num; } continue format_sequence; case '<': case '\{': closing_brace_char = (format_string.charAt(i) === '<' ? '>' : '\}'); hash_parameter_key = ''; i++; for (;; i++) { if (i === len) { self.$raise($$($nesting, 'ArgumentError'), "malformed name - unmatched parenthesis") } if (format_string.charAt(i) === closing_brace_char) { if (pos_arg_num > 0) { self.$raise($$($nesting, 'ArgumentError'), "" + "named " + (hash_parameter_key) + " after unnumbered(" + (pos_arg_num) + ")") } if (pos_arg_num === -1) { self.$raise($$($nesting, 'ArgumentError'), "" + "named " + (hash_parameter_key) + " after numbered") } pos_arg_num = -2; if (args[0] === undefined || !args[0].$$is_hash) { self.$raise($$($nesting, 'ArgumentError'), "one hash required") } next_arg = (args[0]).$fetch(hash_parameter_key); if (closing_brace_char === '>') { continue format_sequence; } else { str = next_arg.toString(); if (precision !== -1) { str = str.slice(0, precision); } if (flags&FMINUS) { while (str.length < width) { str = str + ' '; } } else { while (str.length < width) { str = ' ' + str; } } break format_sequence; } } hash_parameter_key += format_string.charAt(i); } case '*': i++; CHECK_FOR_WIDTH(); flags |= FWIDTH; width = READ_NUM_AFTER_ASTER('width'); if (width < 0) { flags |= FMINUS; width = -width; } continue format_sequence; case '.': if (flags&FPREC0) { self.$raise($$($nesting, 'ArgumentError'), "precision given twice") } flags |= FPREC|FPREC0; precision = 0; i++; if (format_string.charAt(i) === '*') { i++; precision = READ_NUM_AFTER_ASTER('precision'); if (precision < 0) { flags &= ~FPREC; } continue format_sequence; } precision = READ_NUM('precision'); continue format_sequence; case 'd': case 'i': case 'u': arg = self.$Integer(GET_ARG()); if (arg >= 0) { str = arg.toString(); while (str.length < precision) { str = '0' + str; } if (flags&FMINUS) { if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } while (str.length < width) { str = str + ' '; } } else { if (flags&FZERO && precision === -1) { while (str.length < width - ((flags&FPLUS || flags&FSPACE) ? 1 : 0)) { str = '0' + str; } if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } } else { if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } while (str.length < width) { str = ' ' + str; } } } } else { str = (-arg).toString(); while (str.length < precision) { str = '0' + str; } if (flags&FMINUS) { str = '-' + str; while (str.length < width) { str = str + ' '; } } else { if (flags&FZERO && precision === -1) { while (str.length < width - 1) { str = '0' + str; } str = '-' + str; } else { str = '-' + str; while (str.length < width) { str = ' ' + str; } } } } break format_sequence; case 'b': case 'B': case 'o': case 'x': case 'X': switch (format_string.charAt(i)) { case 'b': case 'B': base_number = 2; base_prefix = '0b'; base_neg_zero_regex = /^1+/; base_neg_zero_digit = '1'; break; case 'o': base_number = 8; base_prefix = '0'; base_neg_zero_regex = /^3?7+/; base_neg_zero_digit = '7'; break; case 'x': case 'X': base_number = 16; base_prefix = '0x'; base_neg_zero_regex = /^f+/; base_neg_zero_digit = 'f'; break; } arg = self.$Integer(GET_ARG()); if (arg >= 0) { str = arg.toString(base_number); while (str.length < precision) { str = '0' + str; } if (flags&FMINUS) { if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } if (flags&FSHARP && arg !== 0) { str = base_prefix + str; } while (str.length < width) { str = str + ' '; } } else { if (flags&FZERO && precision === -1) { while (str.length < width - ((flags&FPLUS || flags&FSPACE) ? 1 : 0) - ((flags&FSHARP && arg !== 0) ? base_prefix.length : 0)) { str = '0' + str; } if (flags&FSHARP && arg !== 0) { str = base_prefix + str; } if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } } else { if (flags&FSHARP && arg !== 0) { str = base_prefix + str; } if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } while (str.length < width) { str = ' ' + str; } } } } else { if (flags&FPLUS || flags&FSPACE) { str = (-arg).toString(base_number); while (str.length < precision) { str = '0' + str; } if (flags&FMINUS) { if (flags&FSHARP) { str = base_prefix + str; } str = '-' + str; while (str.length < width) { str = str + ' '; } } else { if (flags&FZERO && precision === -1) { while (str.length < width - 1 - (flags&FSHARP ? 2 : 0)) { str = '0' + str; } if (flags&FSHARP) { str = base_prefix + str; } str = '-' + str; } else { if (flags&FSHARP) { str = base_prefix + str; } str = '-' + str; while (str.length < width) { str = ' ' + str; } } } } else { str = (arg >>> 0).toString(base_number).replace(base_neg_zero_regex, base_neg_zero_digit); while (str.length < precision - 2) { str = base_neg_zero_digit + str; } if (flags&FMINUS) { str = '..' + str; if (flags&FSHARP) { str = base_prefix + str; } while (str.length < width) { str = str + ' '; } } else { if (flags&FZERO && precision === -1) { while (str.length < width - 2 - (flags&FSHARP ? base_prefix.length : 0)) { str = base_neg_zero_digit + str; } str = '..' + str; if (flags&FSHARP) { str = base_prefix + str; } } else { str = '..' + str; if (flags&FSHARP) { str = base_prefix + str; } while (str.length < width) { str = ' ' + str; } } } } } if (format_string.charAt(i) === format_string.charAt(i).toUpperCase()) { str = str.toUpperCase(); } break format_sequence; case 'f': case 'e': case 'E': case 'g': case 'G': arg = self.$Float(GET_ARG()); if (arg >= 0 || isNaN(arg)) { if (arg === Infinity) { str = 'Inf'; } else { switch (format_string.charAt(i)) { case 'f': str = arg.toFixed(precision === -1 ? 6 : precision); break; case 'e': case 'E': str = arg.toExponential(precision === -1 ? 6 : precision); break; case 'g': case 'G': str = arg.toExponential(); exponent = parseInt(str.split('e')[1], 10); if (!(exponent < -4 || exponent >= (precision === -1 ? 6 : precision))) { str = arg.toPrecision(precision === -1 ? (flags&FSHARP ? 6 : undefined) : precision); } break; } } if (flags&FMINUS) { if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } while (str.length < width) { str = str + ' '; } } else { if (flags&FZERO && arg !== Infinity && !isNaN(arg)) { while (str.length < width - ((flags&FPLUS || flags&FSPACE) ? 1 : 0)) { str = '0' + str; } if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } } else { if (flags&FPLUS || flags&FSPACE) { str = (flags&FPLUS ? '+' : ' ') + str; } while (str.length < width) { str = ' ' + str; } } } } else { if (arg === -Infinity) { str = 'Inf'; } else { switch (format_string.charAt(i)) { case 'f': str = (-arg).toFixed(precision === -1 ? 6 : precision); break; case 'e': case 'E': str = (-arg).toExponential(precision === -1 ? 6 : precision); break; case 'g': case 'G': str = (-arg).toExponential(); exponent = parseInt(str.split('e')[1], 10); if (!(exponent < -4 || exponent >= (precision === -1 ? 6 : precision))) { str = (-arg).toPrecision(precision === -1 ? (flags&FSHARP ? 6 : undefined) : precision); } break; } } if (flags&FMINUS) { str = '-' + str; while (str.length < width) { str = str + ' '; } } else { if (flags&FZERO && arg !== -Infinity) { while (str.length < width - 1) { str = '0' + str; } str = '-' + str; } else { str = '-' + str; while (str.length < width) { str = ' ' + str; } } } } if (format_string.charAt(i) === format_string.charAt(i).toUpperCase() && arg !== Infinity && arg !== -Infinity && !isNaN(arg)) { str = str.toUpperCase(); } str = str.replace(/([eE][-+]?)([0-9])$/, '$10$2'); break format_sequence; case 'a': case 'A': // Not implemented because there are no specs for this field type. self.$raise($$($nesting, 'NotImplementedError'), "`A` and `a` format field types are not implemented in Opal yet") case 'c': arg = GET_ARG(); if ((arg)['$respond_to?']("to_ary")) { arg = (arg).$to_ary()[0]; } if ((arg)['$respond_to?']("to_str")) { str = (arg).$to_str(); } else { str = String.fromCharCode($$($nesting, 'Opal').$coerce_to(arg, $$($nesting, 'Integer'), "to_int")); } if (str.length !== 1) { self.$raise($$($nesting, 'ArgumentError'), "%c requires a character") } if (flags&FMINUS) { while (str.length < width) { str = str + ' '; } } else { while (str.length < width) { str = ' ' + str; } } break format_sequence; case 'p': str = (GET_ARG()).$inspect(); if (precision !== -1) { str = str.slice(0, precision); } if (flags&FMINUS) { while (str.length < width) { str = str + ' '; } } else { while (str.length < width) { str = ' ' + str; } } break format_sequence; case 's': str = (GET_ARG()).$to_s(); if (precision !== -1) { str = str.slice(0, precision); } if (flags&FMINUS) { while (str.length < width) { str = str + ' '; } } else { while (str.length < width) { str = ' ' + str; } } break format_sequence; default: self.$raise($$($nesting, 'ArgumentError'), "" + "malformed format string - %" + (format_string.charAt(i))) } } if (str === undefined) { self.$raise($$($nesting, 'ArgumentError'), "malformed format string - %") } result += format_string.slice(begin_slice, end_slice) + str; begin_slice = i + 1; } if ($gvars.DEBUG && pos_arg_num >= 0 && seq_arg_num < args.length) { self.$raise($$($nesting, 'ArgumentError'), "too many arguments for format string") } return result + format_string.slice(begin_slice); ; }, $Kernel_format$1.$$arity = -2); Opal.alias(self, "sprintf", "format"); })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/string/encoding"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var $$12, $$15, $$18, $$21, $$24, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$require', '$+', '$[]', '$new', '$to_proc', '$each', '$const_set', '$sub', '$==', '$default_external', '$upcase', '$raise', '$attr_accessor', '$attr_reader', '$register', '$length', '$bytes', '$to_a', '$each_byte', '$bytesize', '$enum_for', '$each_codepoint', '$force_encoding', '$dup', '$coerce_to!', '$find', '$getbyte']); self.$require("corelib/string"); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Encoding'); var $nesting = [self].concat($parent_nesting), $Encoding_register$1, $Encoding_find$3, $Encoding_initialize$4, $Encoding_ascii_compatible$ques$5, $Encoding_dummy$ques$6, $Encoding_to_s$7, $Encoding_inspect$8, $Encoding_each_byte$9, $Encoding_getbyte$10, $Encoding_bytesize$11; self.$$prototype.ascii = self.$$prototype.dummy = self.$$prototype.name = nil; Opal.defineProperty(self, '$$register', {}); Opal.defs(self, '$register', $Encoding_register$1 = function $$register(name, options) { var $iter = $Encoding_register$1.$$p, block = $iter || nil, $a, $$2, self = this, names = nil, encoding = nil, register = nil; if ($iter) $Encoding_register$1.$$p = null; if ($iter) $Encoding_register$1.$$p = null;; if (options == null) { options = $hash2([], {}); }; names = $rb_plus([name], ($truthy($a = options['$[]']("aliases")) ? $a : [])); encoding = $send($$($nesting, 'Class'), 'new', [self], block.$to_proc()).$new(name, names, ($truthy($a = options['$[]']("ascii")) ? $a : false), ($truthy($a = options['$[]']("dummy")) ? $a : false)); register = self["$$register"]; return $send(names, 'each', [], ($$2 = function(encoding_name){var self = $$2.$$s || this; if (encoding_name == null) { encoding_name = nil; }; self.$const_set(encoding_name.$sub("-", "_"), encoding); return register["" + "$$" + (encoding_name)] = encoding;}, $$2.$$s = self, $$2.$$arity = 1, $$2)); }, $Encoding_register$1.$$arity = -2); Opal.defs(self, '$find', $Encoding_find$3 = function $$find(name) { var $a, self = this, register = nil, encoding = nil; if (name['$==']("default_external")) { return self.$default_external()}; register = self["$$register"]; encoding = ($truthy($a = register["" + "$$" + (name)]) ? $a : register["" + "$$" + (name.$upcase())]); if ($truthy(encoding)) { } else { self.$raise($$($nesting, 'ArgumentError'), "" + "unknown encoding name - " + (name)) }; return encoding; }, $Encoding_find$3.$$arity = 1); (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting); return self.$attr_accessor("default_external") })(Opal.get_singleton_class(self), $nesting); self.$attr_reader("name", "names"); Opal.def(self, '$initialize', $Encoding_initialize$4 = function $$initialize(name, names, ascii, dummy) { var self = this; self.name = name; self.names = names; self.ascii = ascii; return (self.dummy = dummy); }, $Encoding_initialize$4.$$arity = 4); Opal.def(self, '$ascii_compatible?', $Encoding_ascii_compatible$ques$5 = function() { var self = this; return self.ascii }, $Encoding_ascii_compatible$ques$5.$$arity = 0); Opal.def(self, '$dummy?', $Encoding_dummy$ques$6 = function() { var self = this; return self.dummy }, $Encoding_dummy$ques$6.$$arity = 0); Opal.def(self, '$to_s', $Encoding_to_s$7 = function $$to_s() { var self = this; return self.name }, $Encoding_to_s$7.$$arity = 0); Opal.def(self, '$inspect', $Encoding_inspect$8 = function $$inspect() { var self = this; return "" + "#" }, $Encoding_inspect$8.$$arity = 0); Opal.def(self, '$each_byte', $Encoding_each_byte$9 = function $$each_byte($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError')); }, $Encoding_each_byte$9.$$arity = -1); Opal.def(self, '$getbyte', $Encoding_getbyte$10 = function $$getbyte($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError')); }, $Encoding_getbyte$10.$$arity = -1); Opal.def(self, '$bytesize', $Encoding_bytesize$11 = function $$bytesize($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError')); }, $Encoding_bytesize$11.$$arity = -1); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'EncodingError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CompatibilityError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'EncodingError'), $nesting); })($nesting[0], null, $nesting); $send($$($nesting, 'Encoding'), 'register', ["UTF-8", $hash2(["aliases", "ascii"], {"aliases": ["CP65001"], "ascii": true})], ($$12 = function(){var self = $$12.$$s || this, $each_byte$13, $bytesize$14; Opal.def(self, '$each_byte', $each_byte$13 = function $$each_byte(string) { var $iter = $each_byte$13.$$p, block = $iter || nil, self = this; if ($iter) $each_byte$13.$$p = null; if ($iter) $each_byte$13.$$p = null;; for (var i = 0, length = string.length; i < length; i++) { var code = string.charCodeAt(i); if (code <= 0x7f) { Opal.yield1(block, code); } else { var encoded = encodeURIComponent(string.charAt(i)).substr(1).split('%'); for (var j = 0, encoded_length = encoded.length; j < encoded_length; j++) { Opal.yield1(block, parseInt(encoded[j], 16)); } } } ; }, $each_byte$13.$$arity = 1); return (Opal.def(self, '$bytesize', $bytesize$14 = function $$bytesize(string) { var self = this; return string.$bytes().$length() }, $bytesize$14.$$arity = 1), nil) && 'bytesize';}, $$12.$$s = self, $$12.$$arity = 0, $$12)); $send($$($nesting, 'Encoding'), 'register', ["UTF-16LE"], ($$15 = function(){var self = $$15.$$s || this, $each_byte$16, $bytesize$17; Opal.def(self, '$each_byte', $each_byte$16 = function $$each_byte(string) { var $iter = $each_byte$16.$$p, block = $iter || nil, self = this; if ($iter) $each_byte$16.$$p = null; if ($iter) $each_byte$16.$$p = null;; for (var i = 0, length = string.length; i < length; i++) { var code = string.charCodeAt(i); Opal.yield1(block, code & 0xff); Opal.yield1(block, code >> 8); } ; }, $each_byte$16.$$arity = 1); return (Opal.def(self, '$bytesize', $bytesize$17 = function $$bytesize(string) { var self = this; return string.$bytes().$length() }, $bytesize$17.$$arity = 1), nil) && 'bytesize';}, $$15.$$s = self, $$15.$$arity = 0, $$15)); $send($$($nesting, 'Encoding'), 'register', ["UTF-16BE"], ($$18 = function(){var self = $$18.$$s || this, $each_byte$19, $bytesize$20; Opal.def(self, '$each_byte', $each_byte$19 = function $$each_byte(string) { var $iter = $each_byte$19.$$p, block = $iter || nil, self = this; if ($iter) $each_byte$19.$$p = null; if ($iter) $each_byte$19.$$p = null;; for (var i = 0, length = string.length; i < length; i++) { var code = string.charCodeAt(i); Opal.yield1(block, code >> 8); Opal.yield1(block, code & 0xff); } ; }, $each_byte$19.$$arity = 1); return (Opal.def(self, '$bytesize', $bytesize$20 = function $$bytesize(string) { var self = this; return string.$bytes().$length() }, $bytesize$20.$$arity = 1), nil) && 'bytesize';}, $$18.$$s = self, $$18.$$arity = 0, $$18)); $send($$($nesting, 'Encoding'), 'register', ["UTF-32LE"], ($$21 = function(){var self = $$21.$$s || this, $each_byte$22, $bytesize$23; Opal.def(self, '$each_byte', $each_byte$22 = function $$each_byte(string) { var $iter = $each_byte$22.$$p, block = $iter || nil, self = this; if ($iter) $each_byte$22.$$p = null; if ($iter) $each_byte$22.$$p = null;; for (var i = 0, length = string.length; i < length; i++) { var code = string.charCodeAt(i); Opal.yield1(block, code & 0xff); Opal.yield1(block, code >> 8); } ; }, $each_byte$22.$$arity = 1); return (Opal.def(self, '$bytesize', $bytesize$23 = function $$bytesize(string) { var self = this; return string.$bytes().$length() }, $bytesize$23.$$arity = 1), nil) && 'bytesize';}, $$21.$$s = self, $$21.$$arity = 0, $$21)); $send($$($nesting, 'Encoding'), 'register', ["ASCII-8BIT", $hash2(["aliases", "ascii", "dummy"], {"aliases": ["BINARY", "US-ASCII", "ASCII"], "ascii": true, "dummy": true})], ($$24 = function(){var self = $$24.$$s || this, $each_byte$25, $bytesize$26; Opal.def(self, '$each_byte', $each_byte$25 = function $$each_byte(string) { var $iter = $each_byte$25.$$p, block = $iter || nil, self = this; if ($iter) $each_byte$25.$$p = null; if ($iter) $each_byte$25.$$p = null;; for (var i = 0, length = string.length; i < length; i++) { var code = string.charCodeAt(i); Opal.yield1(block, code & 0xff); Opal.yield1(block, code >> 8); } ; }, $each_byte$25.$$arity = 1); return (Opal.def(self, '$bytesize', $bytesize$26 = function $$bytesize(string) { var self = this; return string.$bytes().$length() }, $bytesize$26.$$arity = 1), nil) && 'bytesize';}, $$24.$$s = self, $$24.$$arity = 0, $$24)); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String_bytes$27, $String_bytesize$28, $String_each_byte$29, $String_each_codepoint$30, $String_codepoints$31, $String_encode$32, $String_force_encoding$33, $String_getbyte$34, $String_valid_encoding$ques$35; self.$$prototype.encoding = nil; self.$attr_reader("encoding"); Opal.defineProperty(String.prototype, 'encoding', $$$($$($nesting, 'Encoding'), 'UTF_16LE')); Opal.def(self, '$bytes', $String_bytes$27 = function $$bytes() { var self = this; return self.$each_byte().$to_a() }, $String_bytes$27.$$arity = 0); Opal.def(self, '$bytesize', $String_bytesize$28 = function $$bytesize() { var self = this; return self.encoding.$bytesize(self) }, $String_bytesize$28.$$arity = 0); Opal.def(self, '$each_byte', $String_each_byte$29 = function $$each_byte() { var $iter = $String_each_byte$29.$$p, block = $iter || nil, self = this; if ($iter) $String_each_byte$29.$$p = null; if ($iter) $String_each_byte$29.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("each_byte") }; $send(self.encoding, 'each_byte', [self], block.$to_proc()); return self; }, $String_each_byte$29.$$arity = 0); Opal.def(self, '$each_codepoint', $String_each_codepoint$30 = function $$each_codepoint() { var $iter = $String_each_codepoint$30.$$p, block = $iter || nil, self = this; if ($iter) $String_each_codepoint$30.$$p = null; if ($iter) $String_each_codepoint$30.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("each_codepoint") }; for (var i = 0, length = self.length; i < length; i++) { Opal.yield1(block, self.codePointAt(i)); } ; return self; }, $String_each_codepoint$30.$$arity = 0); Opal.def(self, '$codepoints', $String_codepoints$31 = function $$codepoints() { var $iter = $String_codepoints$31.$$p, block = $iter || nil, self = this; if ($iter) $String_codepoints$31.$$p = null; if ($iter) $String_codepoints$31.$$p = null;; if ((block !== nil)) { return $send(self, 'each_codepoint', [], block.$to_proc())}; return self.$each_codepoint().$to_a(); }, $String_codepoints$31.$$arity = 0); Opal.def(self, '$encode', $String_encode$32 = function $$encode(encoding) { var self = this; return self.$dup().$force_encoding(encoding) }, $String_encode$32.$$arity = 1); Opal.def(self, '$force_encoding', $String_force_encoding$33 = function $$force_encoding(encoding) { var self = this; if (encoding === self.encoding) { return self; } encoding = $$($nesting, 'Opal')['$coerce_to!'](encoding, $$($nesting, 'String'), "to_s"); encoding = $$($nesting, 'Encoding').$find(encoding); if (encoding === self.encoding) { return self; } self.encoding = encoding; return self; }, $String_force_encoding$33.$$arity = 1); Opal.def(self, '$getbyte', $String_getbyte$34 = function $$getbyte(idx) { var self = this; return self.encoding.$getbyte(self, idx) }, $String_getbyte$34.$$arity = 1); return (Opal.def(self, '$valid_encoding?', $String_valid_encoding$ques$35 = function() { var self = this; return true }, $String_valid_encoding$ques$35.$$arity = 0), nil) && 'valid_encoding?'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/math"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy; Opal.add_stubs(['$new', '$raise', '$Float', '$type_error', '$Integer', '$module_function', '$checked', '$float!', '$===', '$gamma', '$-', '$integer!', '$/', '$infinite?']); return (function($base, $parent_nesting) { var self = $module($base, 'Math'); var $nesting = [self].concat($parent_nesting), $Math_checked$1, $Math_float$excl$2, $Math_integer$excl$3, $Math_acos$4, $Math_acosh$5, $Math_asin$6, $Math_asinh$7, $Math_atan$8, $Math_atan2$9, $Math_atanh$10, $Math_cbrt$11, $Math_cos$12, $Math_cosh$13, $Math_erf$14, $Math_erfc$15, $Math_exp$16, $Math_frexp$17, $Math_gamma$18, $Math_hypot$19, $Math_ldexp$20, $Math_lgamma$21, $Math_log$22, $Math_log10$23, $Math_log2$24, $Math_sin$25, $Math_sinh$26, $Math_sqrt$27, $Math_tan$28, $Math_tanh$29; Opal.const_set($nesting[0], 'E', Math.E); Opal.const_set($nesting[0], 'PI', Math.PI); Opal.const_set($nesting[0], 'DomainError', $$($nesting, 'Class').$new($$($nesting, 'StandardError'))); Opal.defs(self, '$checked', $Math_checked$1 = function $$checked(method, $a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if (isNaN(args[0]) || (args.length == 2 && isNaN(args[1]))) { return NaN; } var result = Math[method].apply(null, args); if (isNaN(result)) { self.$raise($$($nesting, 'DomainError'), "" + "Numerical argument is out of domain - \"" + (method) + "\""); } return result; ; }, $Math_checked$1.$$arity = -2); Opal.defs(self, '$float!', $Math_float$excl$2 = function(value) { var self = this; try { return self.$Float(value) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'ArgumentError')])) { try { return self.$raise($$($nesting, 'Opal').$type_error(value, $$($nesting, 'Float'))) } finally { Opal.pop_exception() } } else { throw $err; } } }, $Math_float$excl$2.$$arity = 1); Opal.defs(self, '$integer!', $Math_integer$excl$3 = function(value) { var self = this; try { return self.$Integer(value) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'ArgumentError')])) { try { return self.$raise($$($nesting, 'Opal').$type_error(value, $$($nesting, 'Integer'))) } finally { Opal.pop_exception() } } else { throw $err; } } }, $Math_integer$excl$3.$$arity = 1); self.$module_function(); Opal.def(self, '$acos', $Math_acos$4 = function $$acos(x) { var self = this; return $$($nesting, 'Math').$checked("acos", $$($nesting, 'Math')['$float!'](x)) }, $Math_acos$4.$$arity = 1); if ($truthy((typeof(Math.acosh) !== "undefined"))) { } else { Math.acosh = function(x) { return Math.log(x + Math.sqrt(x * x - 1)); } }; Opal.def(self, '$acosh', $Math_acosh$5 = function $$acosh(x) { var self = this; return $$($nesting, 'Math').$checked("acosh", $$($nesting, 'Math')['$float!'](x)) }, $Math_acosh$5.$$arity = 1); Opal.def(self, '$asin', $Math_asin$6 = function $$asin(x) { var self = this; return $$($nesting, 'Math').$checked("asin", $$($nesting, 'Math')['$float!'](x)) }, $Math_asin$6.$$arity = 1); if ($truthy((typeof(Math.asinh) !== "undefined"))) { } else { Math.asinh = function(x) { return Math.log(x + Math.sqrt(x * x + 1)) } }; Opal.def(self, '$asinh', $Math_asinh$7 = function $$asinh(x) { var self = this; return $$($nesting, 'Math').$checked("asinh", $$($nesting, 'Math')['$float!'](x)) }, $Math_asinh$7.$$arity = 1); Opal.def(self, '$atan', $Math_atan$8 = function $$atan(x) { var self = this; return $$($nesting, 'Math').$checked("atan", $$($nesting, 'Math')['$float!'](x)) }, $Math_atan$8.$$arity = 1); Opal.def(self, '$atan2', $Math_atan2$9 = function $$atan2(y, x) { var self = this; return $$($nesting, 'Math').$checked("atan2", $$($nesting, 'Math')['$float!'](y), $$($nesting, 'Math')['$float!'](x)) }, $Math_atan2$9.$$arity = 2); if ($truthy((typeof(Math.atanh) !== "undefined"))) { } else { Math.atanh = function(x) { return 0.5 * Math.log((1 + x) / (1 - x)); } }; Opal.def(self, '$atanh', $Math_atanh$10 = function $$atanh(x) { var self = this; return $$($nesting, 'Math').$checked("atanh", $$($nesting, 'Math')['$float!'](x)) }, $Math_atanh$10.$$arity = 1); if ($truthy((typeof(Math.cbrt) !== "undefined"))) { } else { Math.cbrt = function(x) { if (x == 0) { return 0; } if (x < 0) { return -Math.cbrt(-x); } var r = x, ex = 0; while (r < 0.125) { r *= 8; ex--; } while (r > 1.0) { r *= 0.125; ex++; } r = (-0.46946116 * r + 1.072302) * r + 0.3812513; while (ex < 0) { r *= 0.5; ex++; } while (ex > 0) { r *= 2; ex--; } r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); r = (2.0 / 3.0) * r + (1.0 / 3.0) * x / (r * r); return r; } }; Opal.def(self, '$cbrt', $Math_cbrt$11 = function $$cbrt(x) { var self = this; return $$($nesting, 'Math').$checked("cbrt", $$($nesting, 'Math')['$float!'](x)) }, $Math_cbrt$11.$$arity = 1); Opal.def(self, '$cos', $Math_cos$12 = function $$cos(x) { var self = this; return $$($nesting, 'Math').$checked("cos", $$($nesting, 'Math')['$float!'](x)) }, $Math_cos$12.$$arity = 1); if ($truthy((typeof(Math.cosh) !== "undefined"))) { } else { Math.cosh = function(x) { return (Math.exp(x) + Math.exp(-x)) / 2; } }; Opal.def(self, '$cosh', $Math_cosh$13 = function $$cosh(x) { var self = this; return $$($nesting, 'Math').$checked("cosh", $$($nesting, 'Math')['$float!'](x)) }, $Math_cosh$13.$$arity = 1); if ($truthy((typeof(Math.erf) !== "undefined"))) { } else { Opal.defineProperty(Math, 'erf', function(x) { var A1 = 0.254829592, A2 = -0.284496736, A3 = 1.421413741, A4 = -1.453152027, A5 = 1.061405429, P = 0.3275911; var sign = 1; if (x < 0) { sign = -1; } x = Math.abs(x); var t = 1.0 / (1.0 + P * x); var y = 1.0 - (((((A5 * t + A4) * t) + A3) * t + A2) * t + A1) * t * Math.exp(-x * x); return sign * y; }); }; Opal.def(self, '$erf', $Math_erf$14 = function $$erf(x) { var self = this; return $$($nesting, 'Math').$checked("erf", $$($nesting, 'Math')['$float!'](x)) }, $Math_erf$14.$$arity = 1); if ($truthy((typeof(Math.erfc) !== "undefined"))) { } else { Opal.defineProperty(Math, 'erfc', function(x) { var z = Math.abs(x), t = 1.0 / (0.5 * z + 1.0); var A1 = t * 0.17087277 + -0.82215223, A2 = t * A1 + 1.48851587, A3 = t * A2 + -1.13520398, A4 = t * A3 + 0.27886807, A5 = t * A4 + -0.18628806, A6 = t * A5 + 0.09678418, A7 = t * A6 + 0.37409196, A8 = t * A7 + 1.00002368, A9 = t * A8, A10 = -z * z - 1.26551223 + A9; var a = t * Math.exp(A10); if (x < 0.0) { return 2.0 - a; } else { return a; } }); }; Opal.def(self, '$erfc', $Math_erfc$15 = function $$erfc(x) { var self = this; return $$($nesting, 'Math').$checked("erfc", $$($nesting, 'Math')['$float!'](x)) }, $Math_erfc$15.$$arity = 1); Opal.def(self, '$exp', $Math_exp$16 = function $$exp(x) { var self = this; return $$($nesting, 'Math').$checked("exp", $$($nesting, 'Math')['$float!'](x)) }, $Math_exp$16.$$arity = 1); Opal.def(self, '$frexp', $Math_frexp$17 = function $$frexp(x) { var self = this; x = $$($nesting, 'Math')['$float!'](x); if (isNaN(x)) { return [NaN, 0]; } var ex = Math.floor(Math.log(Math.abs(x)) / Math.log(2)) + 1, frac = x / Math.pow(2, ex); return [frac, ex]; ; }, $Math_frexp$17.$$arity = 1); Opal.def(self, '$gamma', $Math_gamma$18 = function $$gamma(n) { var self = this; n = $$($nesting, 'Math')['$float!'](n); var i, t, x, value, result, twoN, threeN, fourN, fiveN; var G = 4.7421875; var P = [ 0.99999999999999709182, 57.156235665862923517, -59.597960355475491248, 14.136097974741747174, -0.49191381609762019978, 0.33994649984811888699e-4, 0.46523628927048575665e-4, -0.98374475304879564677e-4, 0.15808870322491248884e-3, -0.21026444172410488319e-3, 0.21743961811521264320e-3, -0.16431810653676389022e-3, 0.84418223983852743293e-4, -0.26190838401581408670e-4, 0.36899182659531622704e-5 ]; if (isNaN(n)) { return NaN; } if (n === 0 && 1 / n < 0) { return -Infinity; } if (n === -1 || n === -Infinity) { self.$raise($$($nesting, 'DomainError'), "Numerical argument is out of domain - \"gamma\""); } if ($$($nesting, 'Integer')['$==='](n)) { if (n <= 0) { return isFinite(n) ? Infinity : NaN; } if (n > 171) { return Infinity; } value = n - 2; result = n - 1; while (value > 1) { result *= value; value--; } if (result == 0) { result = 1; } return result; } if (n < 0.5) { return Math.PI / (Math.sin(Math.PI * n) * $$($nesting, 'Math').$gamma($rb_minus(1, n))); } if (n >= 171.35) { return Infinity; } if (n > 85.0) { twoN = n * n; threeN = twoN * n; fourN = threeN * n; fiveN = fourN * n; return Math.sqrt(2 * Math.PI / n) * Math.pow((n / Math.E), n) * (1 + 1 / (12 * n) + 1 / (288 * twoN) - 139 / (51840 * threeN) - 571 / (2488320 * fourN) + 163879 / (209018880 * fiveN) + 5246819 / (75246796800 * fiveN * n)); } n -= 1; x = P[0]; for (i = 1; i < P.length; ++i) { x += P[i] / (n + i); } t = n + G + 0.5; return Math.sqrt(2 * Math.PI) * Math.pow(t, n + 0.5) * Math.exp(-t) * x; ; }, $Math_gamma$18.$$arity = 1); if ($truthy((typeof(Math.hypot) !== "undefined"))) { } else { Math.hypot = function(x, y) { return Math.sqrt(x * x + y * y) } }; Opal.def(self, '$hypot', $Math_hypot$19 = function $$hypot(x, y) { var self = this; return $$($nesting, 'Math').$checked("hypot", $$($nesting, 'Math')['$float!'](x), $$($nesting, 'Math')['$float!'](y)) }, $Math_hypot$19.$$arity = 2); Opal.def(self, '$ldexp', $Math_ldexp$20 = function $$ldexp(mantissa, exponent) { var self = this; mantissa = $$($nesting, 'Math')['$float!'](mantissa); exponent = $$($nesting, 'Math')['$integer!'](exponent); if (isNaN(exponent)) { self.$raise($$($nesting, 'RangeError'), "float NaN out of range of integer"); } return mantissa * Math.pow(2, exponent); ; }, $Math_ldexp$20.$$arity = 2); Opal.def(self, '$lgamma', $Math_lgamma$21 = function $$lgamma(n) { var self = this; if (n == -1) { return [Infinity, 1]; } else { return [Math.log(Math.abs($$($nesting, 'Math').$gamma(n))), $$($nesting, 'Math').$gamma(n) < 0 ? -1 : 1]; } }, $Math_lgamma$21.$$arity = 1); Opal.def(self, '$log', $Math_log$22 = function $$log(x, base) { var self = this; ; if ($truthy($$($nesting, 'String')['$==='](x))) { self.$raise($$($nesting, 'Opal').$type_error(x, $$($nesting, 'Float')))}; if ($truthy(base == null)) { return $$($nesting, 'Math').$checked("log", $$($nesting, 'Math')['$float!'](x)) } else { if ($truthy($$($nesting, 'String')['$==='](base))) { self.$raise($$($nesting, 'Opal').$type_error(base, $$($nesting, 'Float')))}; return $rb_divide($$($nesting, 'Math').$checked("log", $$($nesting, 'Math')['$float!'](x)), $$($nesting, 'Math').$checked("log", $$($nesting, 'Math')['$float!'](base))); }; }, $Math_log$22.$$arity = -2); if ($truthy((typeof(Math.log10) !== "undefined"))) { } else { Math.log10 = function(x) { return Math.log(x) / Math.LN10; } }; Opal.def(self, '$log10', $Math_log10$23 = function $$log10(x) { var self = this; if ($truthy($$($nesting, 'String')['$==='](x))) { self.$raise($$($nesting, 'Opal').$type_error(x, $$($nesting, 'Float')))}; return $$($nesting, 'Math').$checked("log10", $$($nesting, 'Math')['$float!'](x)); }, $Math_log10$23.$$arity = 1); if ($truthy((typeof(Math.log2) !== "undefined"))) { } else { Math.log2 = function(x) { return Math.log(x) / Math.LN2; } }; Opal.def(self, '$log2', $Math_log2$24 = function $$log2(x) { var self = this; if ($truthy($$($nesting, 'String')['$==='](x))) { self.$raise($$($nesting, 'Opal').$type_error(x, $$($nesting, 'Float')))}; return $$($nesting, 'Math').$checked("log2", $$($nesting, 'Math')['$float!'](x)); }, $Math_log2$24.$$arity = 1); Opal.def(self, '$sin', $Math_sin$25 = function $$sin(x) { var self = this; return $$($nesting, 'Math').$checked("sin", $$($nesting, 'Math')['$float!'](x)) }, $Math_sin$25.$$arity = 1); if ($truthy((typeof(Math.sinh) !== "undefined"))) { } else { Math.sinh = function(x) { return (Math.exp(x) - Math.exp(-x)) / 2; } }; Opal.def(self, '$sinh', $Math_sinh$26 = function $$sinh(x) { var self = this; return $$($nesting, 'Math').$checked("sinh", $$($nesting, 'Math')['$float!'](x)) }, $Math_sinh$26.$$arity = 1); Opal.def(self, '$sqrt', $Math_sqrt$27 = function $$sqrt(x) { var self = this; return $$($nesting, 'Math').$checked("sqrt", $$($nesting, 'Math')['$float!'](x)) }, $Math_sqrt$27.$$arity = 1); Opal.def(self, '$tan', $Math_tan$28 = function $$tan(x) { var self = this; x = $$($nesting, 'Math')['$float!'](x); if ($truthy(x['$infinite?']())) { return $$$($$($nesting, 'Float'), 'NAN')}; return $$($nesting, 'Math').$checked("tan", $$($nesting, 'Math')['$float!'](x)); }, $Math_tan$28.$$arity = 1); if ($truthy((typeof(Math.tanh) !== "undefined"))) { } else { Math.tanh = function(x) { if (x == Infinity) { return 1; } else if (x == -Infinity) { return -1; } else { return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x)); } } }; Opal.def(self, '$tanh', $Math_tanh$29 = function $$tanh(x) { var self = this; return $$($nesting, 'Math').$checked("tanh", $$($nesting, 'Math')['$float!'](x)) }, $Math_tanh$29.$$arity = 1); })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/complex"] = function(Opal) { function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $module = Opal.module; Opal.add_stubs(['$require', '$===', '$real?', '$raise', '$new', '$*', '$cos', '$sin', '$attr_reader', '$class', '$==', '$real', '$imag', '$Complex', '$-@', '$+', '$__coerced__', '$-', '$nan?', '$/', '$conj', '$abs2', '$quo', '$polar', '$exp', '$log', '$>', '$!=', '$divmod', '$**', '$hypot', '$atan2', '$lcm', '$denominator', '$finite?', '$infinite?', '$numerator', '$abs', '$arg', '$rationalize', '$to_f', '$to_i', '$to_r', '$inspect', '$positive?', '$zero?', '$Rational']); self.$require("corelib/numeric"); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Complex'); var $nesting = [self].concat($parent_nesting), $Complex_rect$1, $Complex_polar$2, $Complex_initialize$3, $Complex_coerce$4, $Complex_$eq_eq$5, $Complex_$minus$$6, $Complex_$plus$7, $Complex_$minus$8, $Complex_$$9, $Complex_$slash$10, $Complex_$$$11, $Complex_abs$12, $Complex_abs2$13, $Complex_angle$14, $Complex_conj$15, $Complex_denominator$16, $Complex_eql$ques$17, $Complex_fdiv$18, $Complex_finite$ques$19, $Complex_hash$20, $Complex_infinite$ques$21, $Complex_inspect$22, $Complex_numerator$23, $Complex_polar$24, $Complex_rationalize$25, $Complex_real$ques$26, $Complex_rect$27, $Complex_to_f$28, $Complex_to_i$29, $Complex_to_r$30, $Complex_to_s$31; self.$$prototype.real = self.$$prototype.imag = nil; Opal.defs(self, '$rect', $Complex_rect$1 = function $$rect(real, imag) { var $a, $b, $c, self = this; if (imag == null) { imag = 0; }; if ($truthy(($truthy($a = ($truthy($b = ($truthy($c = $$($nesting, 'Numeric')['$==='](real)) ? real['$real?']() : $c)) ? $$($nesting, 'Numeric')['$==='](imag) : $b)) ? imag['$real?']() : $a))) { } else { self.$raise($$($nesting, 'TypeError'), "not a real") }; return self.$new(real, imag); }, $Complex_rect$1.$$arity = -2); (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting); return Opal.alias(self, "rectangular", "rect") })(Opal.get_singleton_class(self), $nesting); Opal.defs(self, '$polar', $Complex_polar$2 = function $$polar(r, theta) { var $a, $b, $c, self = this; if (theta == null) { theta = 0; }; if ($truthy(($truthy($a = ($truthy($b = ($truthy($c = $$($nesting, 'Numeric')['$==='](r)) ? r['$real?']() : $c)) ? $$($nesting, 'Numeric')['$==='](theta) : $b)) ? theta['$real?']() : $a))) { } else { self.$raise($$($nesting, 'TypeError'), "not a real") }; return self.$new($rb_times(r, $$($nesting, 'Math').$cos(theta)), $rb_times(r, $$($nesting, 'Math').$sin(theta))); }, $Complex_polar$2.$$arity = -2); self.$attr_reader("real", "imag"); Opal.def(self, '$initialize', $Complex_initialize$3 = function $$initialize(real, imag) { var self = this; if (imag == null) { imag = 0; }; self.real = real; return (self.imag = imag); }, $Complex_initialize$3.$$arity = -2); Opal.def(self, '$coerce', $Complex_coerce$4 = function $$coerce(other) { var $a, self = this; if ($truthy($$($nesting, 'Complex')['$==='](other))) { return [other, self] } else if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](other)) ? other['$real?']() : $a))) { return [$$($nesting, 'Complex').$new(other, 0), self] } else { return self.$raise($$($nesting, 'TypeError'), "" + (other.$class()) + " can't be coerced into Complex") } }, $Complex_coerce$4.$$arity = 1); Opal.def(self, '$==', $Complex_$eq_eq$5 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Complex')['$==='](other))) { return (($a = self.real['$=='](other.$real())) ? self.imag['$=='](other.$imag()) : self.real['$=='](other.$real())) } else if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](other)) ? other['$real?']() : $a))) { return (($a = self.real['$=='](other)) ? self.imag['$=='](0) : self.real['$=='](other)) } else { return other['$=='](self) } }, $Complex_$eq_eq$5.$$arity = 1); Opal.def(self, '$-@', $Complex_$minus$$6 = function() { var self = this; return self.$Complex(self.real['$-@'](), self.imag['$-@']()) }, $Complex_$minus$$6.$$arity = 0); Opal.def(self, '$+', $Complex_$plus$7 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Complex')['$==='](other))) { return self.$Complex($rb_plus(self.real, other.$real()), $rb_plus(self.imag, other.$imag())) } else if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](other)) ? other['$real?']() : $a))) { return self.$Complex($rb_plus(self.real, other), self.imag) } else { return self.$__coerced__("+", other) } }, $Complex_$plus$7.$$arity = 1); Opal.def(self, '$-', $Complex_$minus$8 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Complex')['$==='](other))) { return self.$Complex($rb_minus(self.real, other.$real()), $rb_minus(self.imag, other.$imag())) } else if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](other)) ? other['$real?']() : $a))) { return self.$Complex($rb_minus(self.real, other), self.imag) } else { return self.$__coerced__("-", other) } }, $Complex_$minus$8.$$arity = 1); Opal.def(self, '$*', $Complex_$$9 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Complex')['$==='](other))) { return self.$Complex($rb_minus($rb_times(self.real, other.$real()), $rb_times(self.imag, other.$imag())), $rb_plus($rb_times(self.real, other.$imag()), $rb_times(self.imag, other.$real()))) } else if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](other)) ? other['$real?']() : $a))) { return self.$Complex($rb_times(self.real, other), $rb_times(self.imag, other)) } else { return self.$__coerced__("*", other) } }, $Complex_$$9.$$arity = 1); Opal.def(self, '$/', $Complex_$slash$10 = function(other) { var $a, $b, $c, $d, self = this; if ($truthy($$($nesting, 'Complex')['$==='](other))) { if ($truthy(($truthy($a = ($truthy($b = ($truthy($c = ($truthy($d = $$($nesting, 'Number')['$==='](self.real)) ? self.real['$nan?']() : $d)) ? $c : ($truthy($d = $$($nesting, 'Number')['$==='](self.imag)) ? self.imag['$nan?']() : $d))) ? $b : ($truthy($c = $$($nesting, 'Number')['$==='](other.$real())) ? other.$real()['$nan?']() : $c))) ? $a : ($truthy($b = $$($nesting, 'Number')['$==='](other.$imag())) ? other.$imag()['$nan?']() : $b)))) { return $$($nesting, 'Complex').$new($$$($$($nesting, 'Float'), 'NAN'), $$$($$($nesting, 'Float'), 'NAN')) } else { return $rb_divide($rb_times(self, other.$conj()), other.$abs2()) } } else if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](other)) ? other['$real?']() : $a))) { return self.$Complex(self.real.$quo(other), self.imag.$quo(other)) } else { return self.$__coerced__("/", other) } }, $Complex_$slash$10.$$arity = 1); Opal.def(self, '$**', $Complex_$$$11 = function(other) { var $a, $b, $c, $d, self = this, r = nil, theta = nil, ore = nil, oim = nil, nr = nil, ntheta = nil, x = nil, z = nil, n = nil, div = nil, mod = nil; if (other['$=='](0)) { return $$($nesting, 'Complex').$new(1, 0)}; if ($truthy($$($nesting, 'Complex')['$==='](other))) { $b = self.$polar(), $a = Opal.to_ary($b), (r = ($a[0] == null ? nil : $a[0])), (theta = ($a[1] == null ? nil : $a[1])), $b; ore = other.$real(); oim = other.$imag(); nr = $$($nesting, 'Math').$exp($rb_minus($rb_times(ore, $$($nesting, 'Math').$log(r)), $rb_times(oim, theta))); ntheta = $rb_plus($rb_times(theta, ore), $rb_times(oim, $$($nesting, 'Math').$log(r))); return $$($nesting, 'Complex').$polar(nr, ntheta); } else if ($truthy($$($nesting, 'Integer')['$==='](other))) { if ($truthy($rb_gt(other, 0))) { x = self; z = x; n = $rb_minus(other, 1); while ($truthy(n['$!='](0))) { $c = n.$divmod(2), $b = Opal.to_ary($c), (div = ($b[0] == null ? nil : $b[0])), (mod = ($b[1] == null ? nil : $b[1])), $c; while (mod['$=='](0)) { x = self.$Complex($rb_minus($rb_times(x.$real(), x.$real()), $rb_times(x.$imag(), x.$imag())), $rb_times($rb_times(2, x.$real()), x.$imag())); n = div; $d = n.$divmod(2), $c = Opal.to_ary($d), (div = ($c[0] == null ? nil : $c[0])), (mod = ($c[1] == null ? nil : $c[1])), $d; }; z = $rb_times(z, x); n = $rb_minus(n, 1); }; return z; } else { return $rb_divide($$($nesting, 'Rational').$new(1, 1), self)['$**'](other['$-@']()) } } else if ($truthy(($truthy($a = $$($nesting, 'Float')['$==='](other)) ? $a : $$($nesting, 'Rational')['$==='](other)))) { $b = self.$polar(), $a = Opal.to_ary($b), (r = ($a[0] == null ? nil : $a[0])), (theta = ($a[1] == null ? nil : $a[1])), $b; return $$($nesting, 'Complex').$polar(r['$**'](other), $rb_times(theta, other)); } else { return self.$__coerced__("**", other) }; }, $Complex_$$$11.$$arity = 1); Opal.def(self, '$abs', $Complex_abs$12 = function $$abs() { var self = this; return $$($nesting, 'Math').$hypot(self.real, self.imag) }, $Complex_abs$12.$$arity = 0); Opal.def(self, '$abs2', $Complex_abs2$13 = function $$abs2() { var self = this; return $rb_plus($rb_times(self.real, self.real), $rb_times(self.imag, self.imag)) }, $Complex_abs2$13.$$arity = 0); Opal.def(self, '$angle', $Complex_angle$14 = function $$angle() { var self = this; return $$($nesting, 'Math').$atan2(self.imag, self.real) }, $Complex_angle$14.$$arity = 0); Opal.alias(self, "arg", "angle"); Opal.def(self, '$conj', $Complex_conj$15 = function $$conj() { var self = this; return self.$Complex(self.real, self.imag['$-@']()) }, $Complex_conj$15.$$arity = 0); Opal.alias(self, "conjugate", "conj"); Opal.def(self, '$denominator', $Complex_denominator$16 = function $$denominator() { var self = this; return self.real.$denominator().$lcm(self.imag.$denominator()) }, $Complex_denominator$16.$$arity = 0); Opal.alias(self, "divide", "/"); Opal.def(self, '$eql?', $Complex_eql$ques$17 = function(other) { var $a, $b, self = this; return ($truthy($a = ($truthy($b = $$($nesting, 'Complex')['$==='](other)) ? self.real.$class()['$=='](self.imag.$class()) : $b)) ? self['$=='](other) : $a) }, $Complex_eql$ques$17.$$arity = 1); Opal.def(self, '$fdiv', $Complex_fdiv$18 = function $$fdiv(other) { var self = this; if ($truthy($$($nesting, 'Numeric')['$==='](other))) { } else { self.$raise($$($nesting, 'TypeError'), "" + (other.$class()) + " can't be coerced into Complex") }; return $rb_divide(self, other); }, $Complex_fdiv$18.$$arity = 1); Opal.def(self, '$finite?', $Complex_finite$ques$19 = function() { var $a, self = this; return ($truthy($a = self.real['$finite?']()) ? self.imag['$finite?']() : $a) }, $Complex_finite$ques$19.$$arity = 0); Opal.def(self, '$hash', $Complex_hash$20 = function $$hash() { var self = this; return "" + "Complex:" + (self.real) + ":" + (self.imag) }, $Complex_hash$20.$$arity = 0); Opal.alias(self, "imaginary", "imag"); Opal.def(self, '$infinite?', $Complex_infinite$ques$21 = function() { var $a, self = this; return ($truthy($a = self.real['$infinite?']()) ? $a : self.imag['$infinite?']()) }, $Complex_infinite$ques$21.$$arity = 0); Opal.def(self, '$inspect', $Complex_inspect$22 = function $$inspect() { var self = this; return "" + "(" + (self) + ")" }, $Complex_inspect$22.$$arity = 0); Opal.alias(self, "magnitude", "abs"); Opal.udef(self, '$' + "negative?");; Opal.def(self, '$numerator', $Complex_numerator$23 = function $$numerator() { var self = this, d = nil; d = self.$denominator(); return self.$Complex($rb_times(self.real.$numerator(), $rb_divide(d, self.real.$denominator())), $rb_times(self.imag.$numerator(), $rb_divide(d, self.imag.$denominator()))); }, $Complex_numerator$23.$$arity = 0); Opal.alias(self, "phase", "arg"); Opal.def(self, '$polar', $Complex_polar$24 = function $$polar() { var self = this; return [self.$abs(), self.$arg()] }, $Complex_polar$24.$$arity = 0); Opal.udef(self, '$' + "positive?");; Opal.alias(self, "quo", "/"); Opal.def(self, '$rationalize', $Complex_rationalize$25 = function $$rationalize(eps) { var self = this; ; if (arguments.length > 1) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arguments.length) + " for 0..1)"); } ; if ($truthy(self.imag['$!='](0))) { self.$raise($$($nesting, 'RangeError'), "" + "can't' convert " + (self) + " into Rational")}; return self.$real().$rationalize(eps); }, $Complex_rationalize$25.$$arity = -1); Opal.def(self, '$real?', $Complex_real$ques$26 = function() { var self = this; return false }, $Complex_real$ques$26.$$arity = 0); Opal.def(self, '$rect', $Complex_rect$27 = function $$rect() { var self = this; return [self.real, self.imag] }, $Complex_rect$27.$$arity = 0); Opal.alias(self, "rectangular", "rect"); Opal.def(self, '$to_f', $Complex_to_f$28 = function $$to_f() { var self = this; if (self.imag['$=='](0)) { } else { self.$raise($$($nesting, 'RangeError'), "" + "can't convert " + (self) + " into Float") }; return self.real.$to_f(); }, $Complex_to_f$28.$$arity = 0); Opal.def(self, '$to_i', $Complex_to_i$29 = function $$to_i() { var self = this; if (self.imag['$=='](0)) { } else { self.$raise($$($nesting, 'RangeError'), "" + "can't convert " + (self) + " into Integer") }; return self.real.$to_i(); }, $Complex_to_i$29.$$arity = 0); Opal.def(self, '$to_r', $Complex_to_r$30 = function $$to_r() { var self = this; if (self.imag['$=='](0)) { } else { self.$raise($$($nesting, 'RangeError'), "" + "can't convert " + (self) + " into Rational") }; return self.real.$to_r(); }, $Complex_to_r$30.$$arity = 0); Opal.def(self, '$to_s', $Complex_to_s$31 = function $$to_s() { var $a, $b, $c, self = this, result = nil; result = self.real.$inspect(); result = $rb_plus(result, (function() {if ($truthy(($truthy($a = ($truthy($b = ($truthy($c = $$($nesting, 'Number')['$==='](self.imag)) ? self.imag['$nan?']() : $c)) ? $b : self.imag['$positive?']())) ? $a : self.imag['$zero?']()))) { return "+" } else { return "-" }; return nil; })()); result = $rb_plus(result, self.imag.$abs().$inspect()); if ($truthy(($truthy($a = $$($nesting, 'Number')['$==='](self.imag)) ? ($truthy($b = self.imag['$nan?']()) ? $b : self.imag['$infinite?']()) : $a))) { result = $rb_plus(result, "*")}; return $rb_plus(result, "i"); }, $Complex_to_s$31.$$arity = 0); return Opal.const_set($nesting[0], 'I', self.$new(0, 1)); })($nesting[0], $$($nesting, 'Numeric'), $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_Complex$32; Opal.def(self, '$Complex', $Kernel_Complex$32 = function $$Complex(real, imag) { var self = this; if (imag == null) { imag = nil; }; if ($truthy(imag)) { return $$($nesting, 'Complex').$new(real, imag) } else { return $$($nesting, 'Complex').$new(real, 0) }; }, $Kernel_Complex$32.$$arity = -2) })($nesting[0], $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String_to_c$33; return (Opal.def(self, '$to_c', $String_to_c$33 = function $$to_c() { var self = this; var str = self, re = /[+-]?[\d_]+(\.[\d_]+)?(e\d+)?/, match = str.match(re), real, imag, denominator; function isFloat() { return re.test(str); } function cutFloat() { var match = str.match(re); var number = match[0]; str = str.slice(number.length); return number.replace(/_/g, ''); } // handles both floats and rationals function cutNumber() { if (isFloat()) { var numerator = parseFloat(cutFloat()); if (str[0] === '/') { // rational real part str = str.slice(1); if (isFloat()) { var denominator = parseFloat(cutFloat()); return self.$Rational(numerator, denominator); } else { // reverting '/' str = '/' + str; return numerator; } } else { // float real part, no denominator return numerator; } } else { return null; } } real = cutNumber(); if (!real) { if (str[0] === 'i') { // i => Complex(0, 1) return self.$Complex(0, 1); } if (str[0] === '-' && str[1] === 'i') { // -i => Complex(0, -1) return self.$Complex(0, -1); } if (str[0] === '+' && str[1] === 'i') { // +i => Complex(0, 1) return self.$Complex(0, 1); } // anything => Complex(0, 0) return self.$Complex(0, 0); } imag = cutNumber(); if (!imag) { if (str[0] === 'i') { // 3i => Complex(0, 3) return self.$Complex(0, real); } else { // 3 => Complex(3, 0) return self.$Complex(real, 0); } } else { // 3+2i => Complex(3, 2) return self.$Complex(real, imag); } }, $String_to_c$33.$$arity = 0), nil) && 'to_c' })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/rational"] = function(Opal) { function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_le(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $module = Opal.module; Opal.add_stubs(['$require', '$to_i', '$==', '$raise', '$<', '$-@', '$new', '$gcd', '$/', '$nil?', '$===', '$reduce', '$to_r', '$equal?', '$!', '$coerce_to!', '$to_f', '$numerator', '$denominator', '$<=>', '$-', '$*', '$__coerced__', '$+', '$Rational', '$>', '$**', '$abs', '$ceil', '$with_precision', '$floor', '$<=', '$truncate', '$send', '$convert']); self.$require("corelib/numeric"); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Rational'); var $nesting = [self].concat($parent_nesting), $Rational_reduce$1, $Rational_convert$2, $Rational_initialize$3, $Rational_numerator$4, $Rational_denominator$5, $Rational_coerce$6, $Rational_$eq_eq$7, $Rational_$lt_eq_gt$8, $Rational_$plus$9, $Rational_$minus$10, $Rational_$$11, $Rational_$slash$12, $Rational_$$$13, $Rational_abs$14, $Rational_ceil$15, $Rational_floor$16, $Rational_hash$17, $Rational_inspect$18, $Rational_rationalize$19, $Rational_round$20, $Rational_to_f$21, $Rational_to_i$22, $Rational_to_r$23, $Rational_to_s$24, $Rational_truncate$25, $Rational_with_precision$26; self.$$prototype.num = self.$$prototype.den = nil; Opal.defs(self, '$reduce', $Rational_reduce$1 = function $$reduce(num, den) { var self = this, gcd = nil; num = num.$to_i(); den = den.$to_i(); if (den['$=='](0)) { self.$raise($$($nesting, 'ZeroDivisionError'), "divided by 0") } else if ($truthy($rb_lt(den, 0))) { num = num['$-@'](); den = den['$-@'](); } else if (den['$=='](1)) { return self.$new(num, den)}; gcd = num.$gcd(den); return self.$new($rb_divide(num, gcd), $rb_divide(den, gcd)); }, $Rational_reduce$1.$$arity = 2); Opal.defs(self, '$convert', $Rational_convert$2 = function $$convert(num, den) { var $a, $b, self = this; if ($truthy(($truthy($a = num['$nil?']()) ? $a : den['$nil?']()))) { self.$raise($$($nesting, 'TypeError'), "cannot convert nil into Rational")}; if ($truthy(($truthy($a = $$($nesting, 'Integer')['$==='](num)) ? $$($nesting, 'Integer')['$==='](den) : $a))) { return self.$reduce(num, den)}; if ($truthy(($truthy($a = ($truthy($b = $$($nesting, 'Float')['$==='](num)) ? $b : $$($nesting, 'String')['$==='](num))) ? $a : $$($nesting, 'Complex')['$==='](num)))) { num = num.$to_r()}; if ($truthy(($truthy($a = ($truthy($b = $$($nesting, 'Float')['$==='](den)) ? $b : $$($nesting, 'String')['$==='](den))) ? $a : $$($nesting, 'Complex')['$==='](den)))) { den = den.$to_r()}; if ($truthy(($truthy($a = den['$equal?'](1)) ? $$($nesting, 'Integer')['$==='](num)['$!']() : $a))) { return $$($nesting, 'Opal')['$coerce_to!'](num, $$($nesting, 'Rational'), "to_r") } else if ($truthy(($truthy($a = $$($nesting, 'Numeric')['$==='](num)) ? $$($nesting, 'Numeric')['$==='](den) : $a))) { return $rb_divide(num, den) } else { return self.$reduce(num, den) }; }, $Rational_convert$2.$$arity = 2); Opal.def(self, '$initialize', $Rational_initialize$3 = function $$initialize(num, den) { var self = this; self.num = num; return (self.den = den); }, $Rational_initialize$3.$$arity = 2); Opal.def(self, '$numerator', $Rational_numerator$4 = function $$numerator() { var self = this; return self.num }, $Rational_numerator$4.$$arity = 0); Opal.def(self, '$denominator', $Rational_denominator$5 = function $$denominator() { var self = this; return self.den }, $Rational_denominator$5.$$arity = 0); Opal.def(self, '$coerce', $Rational_coerce$6 = function $$coerce(other) { var self = this, $case = nil; return (function() {$case = other; if ($$($nesting, 'Rational')['$===']($case)) {return [other, self]} else if ($$($nesting, 'Integer')['$===']($case)) {return [other.$to_r(), self]} else if ($$($nesting, 'Float')['$===']($case)) {return [other, self.$to_f()]} else { return nil }})() }, $Rational_coerce$6.$$arity = 1); Opal.def(self, '$==', $Rational_$eq_eq$7 = function(other) { var $a, self = this, $case = nil; return (function() {$case = other; if ($$($nesting, 'Rational')['$===']($case)) {return (($a = self.num['$=='](other.$numerator())) ? self.den['$=='](other.$denominator()) : self.num['$=='](other.$numerator()))} else if ($$($nesting, 'Integer')['$===']($case)) {return (($a = self.num['$=='](other)) ? self.den['$=='](1) : self.num['$=='](other))} else if ($$($nesting, 'Float')['$===']($case)) {return self.$to_f()['$=='](other)} else {return other['$=='](self)}})() }, $Rational_$eq_eq$7.$$arity = 1); Opal.def(self, '$<=>', $Rational_$lt_eq_gt$8 = function(other) { var self = this, $case = nil; return (function() {$case = other; if ($$($nesting, 'Rational')['$===']($case)) {return $rb_minus($rb_times(self.num, other.$denominator()), $rb_times(self.den, other.$numerator()))['$<=>'](0)} else if ($$($nesting, 'Integer')['$===']($case)) {return $rb_minus(self.num, $rb_times(self.den, other))['$<=>'](0)} else if ($$($nesting, 'Float')['$===']($case)) {return self.$to_f()['$<=>'](other)} else {return self.$__coerced__("<=>", other)}})() }, $Rational_$lt_eq_gt$8.$$arity = 1); Opal.def(self, '$+', $Rational_$plus$9 = function(other) { var self = this, $case = nil, num = nil, den = nil; return (function() {$case = other; if ($$($nesting, 'Rational')['$===']($case)) { num = $rb_plus($rb_times(self.num, other.$denominator()), $rb_times(self.den, other.$numerator())); den = $rb_times(self.den, other.$denominator()); return self.$Rational(num, den);} else if ($$($nesting, 'Integer')['$===']($case)) {return self.$Rational($rb_plus(self.num, $rb_times(other, self.den)), self.den)} else if ($$($nesting, 'Float')['$===']($case)) {return $rb_plus(self.$to_f(), other)} else {return self.$__coerced__("+", other)}})() }, $Rational_$plus$9.$$arity = 1); Opal.def(self, '$-', $Rational_$minus$10 = function(other) { var self = this, $case = nil, num = nil, den = nil; return (function() {$case = other; if ($$($nesting, 'Rational')['$===']($case)) { num = $rb_minus($rb_times(self.num, other.$denominator()), $rb_times(self.den, other.$numerator())); den = $rb_times(self.den, other.$denominator()); return self.$Rational(num, den);} else if ($$($nesting, 'Integer')['$===']($case)) {return self.$Rational($rb_minus(self.num, $rb_times(other, self.den)), self.den)} else if ($$($nesting, 'Float')['$===']($case)) {return $rb_minus(self.$to_f(), other)} else {return self.$__coerced__("-", other)}})() }, $Rational_$minus$10.$$arity = 1); Opal.def(self, '$*', $Rational_$$11 = function(other) { var self = this, $case = nil, num = nil, den = nil; return (function() {$case = other; if ($$($nesting, 'Rational')['$===']($case)) { num = $rb_times(self.num, other.$numerator()); den = $rb_times(self.den, other.$denominator()); return self.$Rational(num, den);} else if ($$($nesting, 'Integer')['$===']($case)) {return self.$Rational($rb_times(self.num, other), self.den)} else if ($$($nesting, 'Float')['$===']($case)) {return $rb_times(self.$to_f(), other)} else {return self.$__coerced__("*", other)}})() }, $Rational_$$11.$$arity = 1); Opal.def(self, '$/', $Rational_$slash$12 = function(other) { var self = this, $case = nil, num = nil, den = nil; return (function() {$case = other; if ($$($nesting, 'Rational')['$===']($case)) { num = $rb_times(self.num, other.$denominator()); den = $rb_times(self.den, other.$numerator()); return self.$Rational(num, den);} else if ($$($nesting, 'Integer')['$===']($case)) {if (other['$=='](0)) { return $rb_divide(self.$to_f(), 0.0) } else { return self.$Rational(self.num, $rb_times(self.den, other)) }} else if ($$($nesting, 'Float')['$===']($case)) {return $rb_divide(self.$to_f(), other)} else {return self.$__coerced__("/", other)}})() }, $Rational_$slash$12.$$arity = 1); Opal.def(self, '$**', $Rational_$$$13 = function(other) { var $a, self = this, $case = nil; return (function() {$case = other; if ($$($nesting, 'Integer')['$===']($case)) {if ($truthy((($a = self['$=='](0)) ? $rb_lt(other, 0) : self['$=='](0)))) { return $$$($$($nesting, 'Float'), 'INFINITY') } else if ($truthy($rb_gt(other, 0))) { return self.$Rational(self.num['$**'](other), self.den['$**'](other)) } else if ($truthy($rb_lt(other, 0))) { return self.$Rational(self.den['$**'](other['$-@']()), self.num['$**'](other['$-@']())) } else { return self.$Rational(1, 1) }} else if ($$($nesting, 'Float')['$===']($case)) {return self.$to_f()['$**'](other)} else if ($$($nesting, 'Rational')['$===']($case)) {if (other['$=='](0)) { return self.$Rational(1, 1) } else if (other.$denominator()['$=='](1)) { if ($truthy($rb_lt(other, 0))) { return self.$Rational(self.den['$**'](other.$numerator().$abs()), self.num['$**'](other.$numerator().$abs())) } else { return self.$Rational(self.num['$**'](other.$numerator()), self.den['$**'](other.$numerator())) } } else if ($truthy((($a = self['$=='](0)) ? $rb_lt(other, 0) : self['$=='](0)))) { return self.$raise($$($nesting, 'ZeroDivisionError'), "divided by 0") } else { return self.$to_f()['$**'](other) }} else {return self.$__coerced__("**", other)}})() }, $Rational_$$$13.$$arity = 1); Opal.def(self, '$abs', $Rational_abs$14 = function $$abs() { var self = this; return self.$Rational(self.num.$abs(), self.den.$abs()) }, $Rational_abs$14.$$arity = 0); Opal.def(self, '$ceil', $Rational_ceil$15 = function $$ceil(precision) { var self = this; if (precision == null) { precision = 0; }; if (precision['$=='](0)) { return $rb_divide(self.num['$-@'](), self.den)['$-@']().$ceil() } else { return self.$with_precision("ceil", precision) }; }, $Rational_ceil$15.$$arity = -1); Opal.alias(self, "divide", "/"); Opal.def(self, '$floor', $Rational_floor$16 = function $$floor(precision) { var self = this; if (precision == null) { precision = 0; }; if (precision['$=='](0)) { return $rb_divide(self.num['$-@'](), self.den)['$-@']().$floor() } else { return self.$with_precision("floor", precision) }; }, $Rational_floor$16.$$arity = -1); Opal.def(self, '$hash', $Rational_hash$17 = function $$hash() { var self = this; return "" + "Rational:" + (self.num) + ":" + (self.den) }, $Rational_hash$17.$$arity = 0); Opal.def(self, '$inspect', $Rational_inspect$18 = function $$inspect() { var self = this; return "" + "(" + (self) + ")" }, $Rational_inspect$18.$$arity = 0); Opal.alias(self, "quo", "/"); Opal.def(self, '$rationalize', $Rational_rationalize$19 = function $$rationalize(eps) { var self = this; ; if (arguments.length > 1) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (" + (arguments.length) + " for 0..1)"); } if (eps == null) { return self; } var e = eps.$abs(), a = $rb_minus(self, e), b = $rb_plus(self, e); var p0 = 0, p1 = 1, q0 = 1, q1 = 0, p2, q2; var c, k, t; while (true) { c = (a).$ceil(); if ($rb_le(c, b)) { break; } k = c - 1; p2 = k * p1 + p0; q2 = k * q1 + q0; t = $rb_divide(1, $rb_minus(b, k)); b = $rb_divide(1, $rb_minus(a, k)); a = t; p0 = p1; q0 = q1; p1 = p2; q1 = q2; } return self.$Rational(c * p1 + p0, c * q1 + q0); ; }, $Rational_rationalize$19.$$arity = -1); Opal.def(self, '$round', $Rational_round$20 = function $$round(precision) { var self = this, num = nil, den = nil, approx = nil; if (precision == null) { precision = 0; }; if (precision['$=='](0)) { } else { return self.$with_precision("round", precision) }; if (self.num['$=='](0)) { return 0}; if (self.den['$=='](1)) { return self.num}; num = $rb_plus($rb_times(self.num.$abs(), 2), self.den); den = $rb_times(self.den, 2); approx = $rb_divide(num, den).$truncate(); if ($truthy($rb_lt(self.num, 0))) { return approx['$-@']() } else { return approx }; }, $Rational_round$20.$$arity = -1); Opal.def(self, '$to_f', $Rational_to_f$21 = function $$to_f() { var self = this; return $rb_divide(self.num, self.den) }, $Rational_to_f$21.$$arity = 0); Opal.def(self, '$to_i', $Rational_to_i$22 = function $$to_i() { var self = this; return self.$truncate() }, $Rational_to_i$22.$$arity = 0); Opal.def(self, '$to_r', $Rational_to_r$23 = function $$to_r() { var self = this; return self }, $Rational_to_r$23.$$arity = 0); Opal.def(self, '$to_s', $Rational_to_s$24 = function $$to_s() { var self = this; return "" + (self.num) + "/" + (self.den) }, $Rational_to_s$24.$$arity = 0); Opal.def(self, '$truncate', $Rational_truncate$25 = function $$truncate(precision) { var self = this; if (precision == null) { precision = 0; }; if (precision['$=='](0)) { if ($truthy($rb_lt(self.num, 0))) { return self.$ceil() } else { return self.$floor() } } else { return self.$with_precision("truncate", precision) }; }, $Rational_truncate$25.$$arity = -1); return (Opal.def(self, '$with_precision', $Rational_with_precision$26 = function $$with_precision(method, precision) { var self = this, p = nil, s = nil; if ($truthy($$($nesting, 'Integer')['$==='](precision))) { } else { self.$raise($$($nesting, 'TypeError'), "not an Integer") }; p = (10)['$**'](precision); s = $rb_times(self, p); if ($truthy($rb_lt(precision, 1))) { return $rb_divide(s.$send(method), p).$to_i() } else { return self.$Rational(s.$send(method), p) }; }, $Rational_with_precision$26.$$arity = 2), nil) && 'with_precision'; })($nesting[0], $$($nesting, 'Numeric'), $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_Rational$27; Opal.def(self, '$Rational', $Kernel_Rational$27 = function $$Rational(numerator, denominator) { var self = this; if (denominator == null) { denominator = 1; }; return $$($nesting, 'Rational').$convert(numerator, denominator); }, $Kernel_Rational$27.$$arity = -2) })($nesting[0], $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String_to_r$28; return (Opal.def(self, '$to_r', $String_to_r$28 = function $$to_r() { var self = this; var str = self.trimLeft(), re = /^[+-]?[\d_]+(\.[\d_]+)?/, match = str.match(re), numerator, denominator; function isFloat() { return re.test(str); } function cutFloat() { var match = str.match(re); var number = match[0]; str = str.slice(number.length); return number.replace(/_/g, ''); } if (isFloat()) { numerator = parseFloat(cutFloat()); if (str[0] === '/') { // rational real part str = str.slice(1); if (isFloat()) { denominator = parseFloat(cutFloat()); return self.$Rational(numerator, denominator); } else { return self.$Rational(numerator, 1); } } else { return self.$Rational(numerator, 1); } } else { return self.$Rational(0, 1); } }, $String_to_r$28.$$arity = 0), nil) && 'to_r' })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/time"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_le(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $range = Opal.range; Opal.add_stubs(['$require', '$include', '$===', '$raise', '$coerce_to!', '$respond_to?', '$to_str', '$to_i', '$new', '$<=>', '$to_f', '$nil?', '$>', '$<', '$strftime', '$year', '$month', '$day', '$+', '$round', '$/', '$-', '$copy_instance_variables', '$initialize_dup', '$is_a?', '$zero?', '$wday', '$utc?', '$mon', '$yday', '$hour', '$min', '$sec', '$rjust', '$ljust', '$zone', '$to_s', '$[]', '$cweek_cyear', '$isdst', '$<=', '$!=', '$==', '$ceil']); self.$require("corelib/comparable"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Time'); var $nesting = [self].concat($parent_nesting), $Time_at$1, $Time_new$2, $Time_local$3, $Time_gm$4, $Time_now$5, $Time_$plus$6, $Time_$minus$7, $Time_$lt_eq_gt$8, $Time_$eq_eq$9, $Time_asctime$10, $Time_day$11, $Time_yday$12, $Time_isdst$13, $Time_dup$14, $Time_eql$ques$15, $Time_friday$ques$16, $Time_hash$17, $Time_hour$18, $Time_inspect$19, $Time_min$20, $Time_mon$21, $Time_monday$ques$22, $Time_saturday$ques$23, $Time_sec$24, $Time_succ$25, $Time_usec$26, $Time_zone$27, $Time_getgm$28, $Time_gmtime$29, $Time_gmt$ques$30, $Time_gmt_offset$31, $Time_strftime$32, $Time_sunday$ques$33, $Time_thursday$ques$34, $Time_to_a$35, $Time_to_f$36, $Time_to_i$37, $Time_tuesday$ques$38, $Time_wday$39, $Time_wednesday$ques$40, $Time_year$41, $Time_cweek_cyear$42; self.$include($$($nesting, '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', $Time_at$1 = function $$at(seconds, frac) { var self = this; ; var result; if ($$($nesting, 'Time')['$==='](seconds)) { if (frac !== undefined) { self.$raise($$($nesting, 'TypeError'), "can't convert Time into an exact number") } result = new Date(seconds.getTime()); result.is_utc = seconds.is_utc; return result; } if (!seconds.$$is_number) { seconds = $$($nesting, 'Opal')['$coerce_to!'](seconds, $$($nesting, 'Integer'), "to_int"); } if (frac === undefined) { return new Date(seconds * 1000); } if (!frac.$$is_number) { frac = $$($nesting, 'Opal')['$coerce_to!'](frac, $$($nesting, 'Integer'), "to_int"); } return new Date(seconds * 1000 + (frac / 1000)); ; }, $Time_at$1.$$arity = -2); function time_params(year, month, day, hour, min, sec) { if (year.$$is_string) { year = parseInt(year, 10); } else { year = $$($nesting, 'Opal')['$coerce_to!'](year, $$($nesting, 'Integer'), "to_int"); } if (month === nil) { month = 1; } else if (!month.$$is_number) { if ((month)['$respond_to?']("to_str")) { month = (month).$to_str(); switch (month.toLowerCase()) { case 'jan': month = 1; break; case 'feb': month = 2; break; case 'mar': month = 3; break; case 'apr': month = 4; break; case 'may': month = 5; break; case 'jun': month = 6; break; case 'jul': month = 7; break; case 'aug': month = 8; break; case 'sep': month = 9; break; case 'oct': month = 10; break; case 'nov': month = 11; break; case 'dec': month = 12; break; default: month = (month).$to_i(); } } else { month = $$($nesting, 'Opal')['$coerce_to!'](month, $$($nesting, 'Integer'), "to_int"); } } if (month < 1 || month > 12) { self.$raise($$($nesting, 'ArgumentError'), "" + "month out of range: " + (month)) } month = month - 1; if (day === nil) { day = 1; } else if (day.$$is_string) { day = parseInt(day, 10); } else { day = $$($nesting, 'Opal')['$coerce_to!'](day, $$($nesting, 'Integer'), "to_int"); } if (day < 1 || day > 31) { self.$raise($$($nesting, 'ArgumentError'), "" + "day out of range: " + (day)) } if (hour === nil) { hour = 0; } else if (hour.$$is_string) { hour = parseInt(hour, 10); } else { hour = $$($nesting, 'Opal')['$coerce_to!'](hour, $$($nesting, 'Integer'), "to_int"); } if (hour < 0 || hour > 24) { self.$raise($$($nesting, 'ArgumentError'), "" + "hour out of range: " + (hour)) } if (min === nil) { min = 0; } else if (min.$$is_string) { min = parseInt(min, 10); } else { min = $$($nesting, 'Opal')['$coerce_to!'](min, $$($nesting, 'Integer'), "to_int"); } if (min < 0 || min > 59) { self.$raise($$($nesting, 'ArgumentError'), "" + "min out of range: " + (min)) } if (sec === nil) { sec = 0; } else if (!sec.$$is_number) { if (sec.$$is_string) { sec = parseInt(sec, 10); } else { sec = $$($nesting, 'Opal')['$coerce_to!'](sec, $$($nesting, 'Integer'), "to_int"); } } if (sec < 0 || sec > 60) { self.$raise($$($nesting, 'ArgumentError'), "" + "sec out of range: " + (sec)) } return [year, month, day, hour, min, sec]; } ; Opal.defs(self, '$new', $Time_new$2 = function(year, month, day, hour, min, sec, utc_offset) { var self = this; ; if (month == null) { month = nil; }; if (day == null) { day = nil; }; if (hour == null) { hour = nil; }; if (min == null) { min = nil; }; if (sec == null) { sec = nil; }; if (utc_offset == null) { utc_offset = nil; }; var args, result; if (year === undefined) { return new Date(); } if (utc_offset !== nil) { self.$raise($$($nesting, 'ArgumentError'), "Opal does not support explicitly specifying UTC offset for Time") } args = time_params(year, month, day, hour, min, sec); year = args[0]; month = args[1]; day = args[2]; hour = args[3]; min = args[4]; sec = args[5]; result = new Date(year, month, day, hour, min, 0, sec * 1000); if (year < 100) { result.setFullYear(year); } return result; ; }, $Time_new$2.$$arity = -1); Opal.defs(self, '$local', $Time_local$3 = function $$local(year, month, day, hour, min, sec, millisecond, _dummy1, _dummy2, _dummy3) { var self = this; if (month == null) { month = nil; }; if (day == null) { day = nil; }; if (hour == null) { hour = nil; }; if (min == null) { min = nil; }; if (sec == null) { sec = nil; }; if (millisecond == null) { millisecond = nil; }; if (_dummy1 == null) { _dummy1 = nil; }; if (_dummy2 == null) { _dummy2 = nil; }; if (_dummy3 == null) { _dummy3 = nil; }; var args, result; if (arguments.length === 10) { args = $slice.call(arguments); year = args[5]; month = args[4]; day = args[3]; hour = args[2]; min = args[1]; sec = args[0]; } args = time_params(year, month, day, hour, min, sec); year = args[0]; month = args[1]; day = args[2]; hour = args[3]; min = args[4]; sec = args[5]; result = new Date(year, month, day, hour, min, 0, sec * 1000); if (year < 100) { result.setFullYear(year); } return result; ; }, $Time_local$3.$$arity = -2); Opal.defs(self, '$gm', $Time_gm$4 = function $$gm(year, month, day, hour, min, sec, millisecond, _dummy1, _dummy2, _dummy3) { var self = this; if (month == null) { month = nil; }; if (day == null) { day = nil; }; if (hour == null) { hour = nil; }; if (min == null) { min = nil; }; if (sec == null) { sec = nil; }; if (millisecond == null) { millisecond = nil; }; if (_dummy1 == null) { _dummy1 = nil; }; if (_dummy2 == null) { _dummy2 = nil; }; if (_dummy3 == null) { _dummy3 = nil; }; var args, result; if (arguments.length === 10) { args = $slice.call(arguments); year = args[5]; month = args[4]; day = args[3]; hour = args[2]; min = args[1]; sec = args[0]; } args = time_params(year, month, day, hour, min, sec); year = args[0]; month = args[1]; day = args[2]; hour = args[3]; min = args[4]; sec = args[5]; result = new Date(Date.UTC(year, month, day, hour, min, 0, sec * 1000)); if (year < 100) { result.setUTCFullYear(year); } result.is_utc = true; return result; ; }, $Time_gm$4.$$arity = -2); (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting); Opal.alias(self, "mktime", "local"); return Opal.alias(self, "utc", "gm"); })(Opal.get_singleton_class(self), $nesting); Opal.defs(self, '$now', $Time_now$5 = function $$now() { var self = this; return self.$new() }, $Time_now$5.$$arity = 0); Opal.def(self, '$+', $Time_$plus$6 = function(other) { var self = this; if ($truthy($$($nesting, 'Time')['$==='](other))) { self.$raise($$($nesting, 'TypeError'), "time + time?")}; if (!other.$$is_number) { other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Integer'), "to_int"); } var result = new Date(self.getTime() + (other * 1000)); result.is_utc = self.is_utc; return result; ; }, $Time_$plus$6.$$arity = 1); Opal.def(self, '$-', $Time_$minus$7 = function(other) { var self = this; if ($truthy($$($nesting, 'Time')['$==='](other))) { return (self.getTime() - other.getTime()) / 1000}; if (!other.$$is_number) { other = $$($nesting, 'Opal')['$coerce_to!'](other, $$($nesting, 'Integer'), "to_int"); } var result = new Date(self.getTime() - (other * 1000)); result.is_utc = self.is_utc; return result; ; }, $Time_$minus$7.$$arity = 1); Opal.def(self, '$<=>', $Time_$lt_eq_gt$8 = function(other) { var self = this, r = nil; if ($truthy($$($nesting, 'Time')['$==='](other))) { return self.$to_f()['$<=>'](other.$to_f()) } else { r = other['$<=>'](self); if ($truthy(r['$nil?']())) { return nil } else if ($truthy($rb_gt(r, 0))) { return -1 } else if ($truthy($rb_lt(r, 0))) { return 1 } else { return 0 }; } }, $Time_$lt_eq_gt$8.$$arity = 1); Opal.def(self, '$==', $Time_$eq_eq$9 = function(other) { var $a, self = this; return ($truthy($a = $$($nesting, 'Time')['$==='](other)) ? self.$to_f() === other.$to_f() : $a) }, $Time_$eq_eq$9.$$arity = 1); Opal.def(self, '$asctime', $Time_asctime$10 = function $$asctime() { var self = this; return self.$strftime("%a %b %e %H:%M:%S %Y") }, $Time_asctime$10.$$arity = 0); Opal.alias(self, "ctime", "asctime"); Opal.def(self, '$day', $Time_day$11 = function $$day() { var self = this; return self.is_utc ? self.getUTCDate() : self.getDate(); }, $Time_day$11.$$arity = 0); Opal.def(self, '$yday', $Time_yday$12 = function $$yday() { var self = this, start_of_year = nil, start_of_day = nil, one_day = nil; start_of_year = $$($nesting, 'Time').$new(self.$year()).$to_i(); start_of_day = $$($nesting, 'Time').$new(self.$year(), self.$month(), self.$day()).$to_i(); one_day = 86400; return $rb_plus($rb_divide($rb_minus(start_of_day, start_of_year), one_day).$round(), 1); }, $Time_yday$12.$$arity = 0); Opal.def(self, '$isdst', $Time_isdst$13 = function $$isdst() { var self = this; var jan = new Date(self.getFullYear(), 0, 1), jul = new Date(self.getFullYear(), 6, 1); return self.getTimezoneOffset() < Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); }, $Time_isdst$13.$$arity = 0); Opal.alias(self, "dst?", "isdst"); Opal.def(self, '$dup', $Time_dup$14 = function $$dup() { var self = this, copy = nil; copy = new Date(self.getTime()); copy.$copy_instance_variables(self); copy.$initialize_dup(self); return copy; }, $Time_dup$14.$$arity = 0); Opal.def(self, '$eql?', $Time_eql$ques$15 = function(other) { var $a, self = this; return ($truthy($a = other['$is_a?']($$($nesting, 'Time'))) ? self['$<=>'](other)['$zero?']() : $a) }, $Time_eql$ques$15.$$arity = 1); Opal.def(self, '$friday?', $Time_friday$ques$16 = function() { var self = this; return self.$wday() == 5 }, $Time_friday$ques$16.$$arity = 0); Opal.def(self, '$hash', $Time_hash$17 = function $$hash() { var self = this; return 'Time:' + self.getTime(); }, $Time_hash$17.$$arity = 0); Opal.def(self, '$hour', $Time_hour$18 = function $$hour() { var self = this; return self.is_utc ? self.getUTCHours() : self.getHours(); }, $Time_hour$18.$$arity = 0); Opal.def(self, '$inspect', $Time_inspect$19 = function $$inspect() { var self = this; if ($truthy(self['$utc?']())) { return self.$strftime("%Y-%m-%d %H:%M:%S UTC") } else { return self.$strftime("%Y-%m-%d %H:%M:%S %z") } }, $Time_inspect$19.$$arity = 0); Opal.alias(self, "mday", "day"); Opal.def(self, '$min', $Time_min$20 = function $$min() { var self = this; return self.is_utc ? self.getUTCMinutes() : self.getMinutes(); }, $Time_min$20.$$arity = 0); Opal.def(self, '$mon', $Time_mon$21 = function $$mon() { var self = this; return (self.is_utc ? self.getUTCMonth() : self.getMonth()) + 1; }, $Time_mon$21.$$arity = 0); Opal.def(self, '$monday?', $Time_monday$ques$22 = function() { var self = this; return self.$wday() == 1 }, $Time_monday$ques$22.$$arity = 0); Opal.alias(self, "month", "mon"); Opal.def(self, '$saturday?', $Time_saturday$ques$23 = function() { var self = this; return self.$wday() == 6 }, $Time_saturday$ques$23.$$arity = 0); Opal.def(self, '$sec', $Time_sec$24 = function $$sec() { var self = this; return self.is_utc ? self.getUTCSeconds() : self.getSeconds(); }, $Time_sec$24.$$arity = 0); Opal.def(self, '$succ', $Time_succ$25 = function $$succ() { var self = this; var result = new Date(self.getTime() + 1000); result.is_utc = self.is_utc; return result; }, $Time_succ$25.$$arity = 0); Opal.def(self, '$usec', $Time_usec$26 = function $$usec() { var self = this; return self.getMilliseconds() * 1000; }, $Time_usec$26.$$arity = 0); Opal.def(self, '$zone', $Time_zone$27 = function $$zone() { var self = this; var string = self.toString(), result; if (string.indexOf('(') == -1) { result = string.match(/[A-Z]{3,4}/)[0]; } else { result = string.match(/\((.+)\)(?:\s|$)/)[1] } if (result == "GMT" && /(GMT\W*\d{4})/.test(string)) { return RegExp.$1; } else { return result; } }, $Time_zone$27.$$arity = 0); Opal.def(self, '$getgm', $Time_getgm$28 = function $$getgm() { var self = this; var result = new Date(self.getTime()); result.is_utc = true; return result; }, $Time_getgm$28.$$arity = 0); Opal.alias(self, "getutc", "getgm"); Opal.def(self, '$gmtime', $Time_gmtime$29 = function $$gmtime() { var self = this; self.is_utc = true; return self; }, $Time_gmtime$29.$$arity = 0); Opal.alias(self, "utc", "gmtime"); Opal.def(self, '$gmt?', $Time_gmt$ques$30 = function() { var self = this; return self.is_utc === true; }, $Time_gmt$ques$30.$$arity = 0); Opal.def(self, '$gmt_offset', $Time_gmt_offset$31 = function $$gmt_offset() { var self = this; return self.is_utc ? 0 : -self.getTimezoneOffset() * 60; }, $Time_gmt_offset$31.$$arity = 0); Opal.def(self, '$strftime', $Time_strftime$32 = function $$strftime(format) { var self = this; return format.replace(/%([\-_#^0]*:{0,2})(\d+)?([EO]*)(.)/g, function(full, flags, width, _, conv) { var result = "", 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; width = parseInt(width, 10); 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; }); }, $Time_strftime$32.$$arity = 1); Opal.def(self, '$sunday?', $Time_sunday$ques$33 = function() { var self = this; return self.$wday() == 0 }, $Time_sunday$ques$33.$$arity = 0); Opal.def(self, '$thursday?', $Time_thursday$ques$34 = function() { var self = this; return self.$wday() == 4 }, $Time_thursday$ques$34.$$arity = 0); Opal.def(self, '$to_a', $Time_to_a$35 = function $$to_a() { var self = this; return [self.$sec(), self.$min(), self.$hour(), self.$day(), self.$month(), self.$year(), self.$wday(), self.$yday(), self.$isdst(), self.$zone()] }, $Time_to_a$35.$$arity = 0); Opal.def(self, '$to_f', $Time_to_f$36 = function $$to_f() { var self = this; return self.getTime() / 1000; }, $Time_to_f$36.$$arity = 0); Opal.def(self, '$to_i', $Time_to_i$37 = function $$to_i() { var self = this; return parseInt(self.getTime() / 1000, 10); }, $Time_to_i$37.$$arity = 0); Opal.alias(self, "to_s", "inspect"); Opal.def(self, '$tuesday?', $Time_tuesday$ques$38 = function() { var self = this; return self.$wday() == 2 }, $Time_tuesday$ques$38.$$arity = 0); Opal.alias(self, "tv_sec", "to_i"); Opal.alias(self, "tv_usec", "usec"); Opal.alias(self, "utc?", "gmt?"); Opal.alias(self, "gmtoff", "gmt_offset"); Opal.alias(self, "utc_offset", "gmt_offset"); Opal.def(self, '$wday', $Time_wday$39 = function $$wday() { var self = this; return self.is_utc ? self.getUTCDay() : self.getDay(); }, $Time_wday$39.$$arity = 0); Opal.def(self, '$wednesday?', $Time_wednesday$ques$40 = function() { var self = this; return self.$wday() == 3 }, $Time_wednesday$ques$40.$$arity = 0); Opal.def(self, '$year', $Time_year$41 = function $$year() { var self = this; return self.is_utc ? self.getUTCFullYear() : self.getFullYear(); }, $Time_year$41.$$arity = 0); return (Opal.def(self, '$cweek_cyear', $Time_cweek_cyear$42 = function $$cweek_cyear() { var $a, self = this, jan01 = nil, jan01_wday = nil, first_monday = nil, year = nil, offset = nil, week = nil, dec31 = nil, dec31_wday = nil; jan01 = $$($nesting, 'Time').$new(self.$year(), 1, 1); jan01_wday = jan01.$wday(); first_monday = 0; year = self.$year(); if ($truthy(($truthy($a = $rb_le(jan01_wday, 4)) ? jan01_wday['$!='](0) : $a))) { offset = $rb_minus(jan01_wday, 1) } else { offset = $rb_minus($rb_minus(jan01_wday, 7), 1); if (offset['$=='](-8)) { offset = -1}; }; week = $rb_divide($rb_plus(self.$yday(), offset), 7.0).$ceil(); if ($truthy($rb_le(week, 0))) { return $$($nesting, 'Time').$new($rb_minus(self.$year(), 1), 12, 31).$cweek_cyear() } else if (week['$=='](53)) { dec31 = $$($nesting, 'Time').$new(self.$year(), 12, 31); dec31_wday = dec31.$wday(); if ($truthy(($truthy($a = $rb_le(dec31_wday, 3)) ? dec31_wday['$!='](0) : $a))) { week = 1; year = $rb_plus(year, 1);};}; return [week, year]; }, $Time_cweek_cyear$42.$$arity = 0), nil) && 'cweek_cyear'; })($nesting[0], Date, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/struct"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } function $rb_ge(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$require', '$include', '$const_name!', '$unshift', '$map', '$coerce_to!', '$new', '$each', '$define_struct_attribute', '$allocate', '$initialize', '$alias_method', '$module_eval', '$to_proc', '$const_set', '$==', '$raise', '$<<', '$members', '$define_method', '$instance_eval', '$class', '$last', '$>', '$length', '$-', '$keys', '$any?', '$join', '$[]', '$[]=', '$each_with_index', '$hash', '$===', '$<', '$-@', '$size', '$>=', '$include?', '$to_sym', '$instance_of?', '$__id__', '$eql?', '$enum_for', '$name', '$+', '$each_pair', '$inspect', '$each_with_object', '$flatten', '$to_a', '$respond_to?', '$dig']); self.$require("corelib/enumerable"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Struct'); var $nesting = [self].concat($parent_nesting), $Struct_new$1, $Struct_define_struct_attribute$6, $Struct_members$9, $Struct_inherited$10, $Struct_initialize$12, $Struct_members$15, $Struct_hash$16, $Struct_$$$17, $Struct_$$$eq$18, $Struct_$eq_eq$19, $Struct_eql$ques$20, $Struct_each$21, $Struct_each_pair$24, $Struct_length$27, $Struct_to_a$28, $Struct_inspect$30, $Struct_to_h$32, $Struct_values_at$34, $Struct_dig$36; self.$include($$($nesting, 'Enumerable')); Opal.defs(self, '$new', $Struct_new$1 = function(const_name, $a, $b) { var $iter = $Struct_new$1.$$p, block = $iter || nil, $post_args, $kwargs, args, keyword_init, $$2, $$3, self = this, klass = nil; if ($iter) $Struct_new$1.$$p = null; if ($iter) $Struct_new$1.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); $kwargs = Opal.extract_kwargs($post_args); if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; args = $post_args;; keyword_init = $kwargs.$$smap["keyword_init"]; if (keyword_init == null) { keyword_init = false }; if ($truthy(const_name)) { try { const_name = $$($nesting, 'Opal')['$const_name!'](const_name) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'TypeError'), $$($nesting, 'NameError')])) { try { args.$unshift(const_name); const_name = nil; } finally { Opal.pop_exception() } } else { throw $err; } };}; $send(args, 'map', [], ($$2 = function(arg){var self = $$2.$$s || this; if (arg == null) { arg = nil; }; return $$($nesting, 'Opal')['$coerce_to!'](arg, $$($nesting, 'String'), "to_str");}, $$2.$$s = self, $$2.$$arity = 1, $$2)); klass = $send($$($nesting, 'Class'), 'new', [self], ($$3 = function(){var self = $$3.$$s || this, $$4; $send(args, 'each', [], ($$4 = function(arg){var self = $$4.$$s || this; if (arg == null) { arg = nil; }; return self.$define_struct_attribute(arg);}, $$4.$$s = self, $$4.$$arity = 1, $$4)); return (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $new$5; Opal.def(self, '$new', $new$5 = function($a) { var $post_args, args, self = this, instance = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; instance = self.$allocate(); instance.$$data = {}; $send(instance, 'initialize', Opal.to_a(args)); return instance; }, $new$5.$$arity = -1); return self.$alias_method("[]", "new"); })(Opal.get_singleton_class(self), $nesting);}, $$3.$$s = self, $$3.$$arity = 0, $$3)); if ($truthy(block)) { $send(klass, 'module_eval', [], block.$to_proc())}; klass.$$keyword_init = keyword_init; if ($truthy(const_name)) { $$($nesting, 'Struct').$const_set(const_name, klass)}; return klass; }, $Struct_new$1.$$arity = -2); Opal.defs(self, '$define_struct_attribute', $Struct_define_struct_attribute$6 = function $$define_struct_attribute(name) { var $$7, $$8, self = this; if (self['$==']($$($nesting, 'Struct'))) { self.$raise($$($nesting, 'ArgumentError'), "you cannot define attributes to the Struct class")}; self.$members()['$<<'](name); $send(self, 'define_method', [name], ($$7 = function(){var self = $$7.$$s || this; return self.$$data[name];}, $$7.$$s = self, $$7.$$arity = 0, $$7)); return $send(self, 'define_method', ["" + (name) + "="], ($$8 = function(value){var self = $$8.$$s || this; if (value == null) { value = nil; }; return self.$$data[name] = value;;}, $$8.$$s = self, $$8.$$arity = 1, $$8)); }, $Struct_define_struct_attribute$6.$$arity = 1); Opal.defs(self, '$members', $Struct_members$9 = function $$members() { var $a, self = this; if (self.members == null) self.members = nil; if (self['$==']($$($nesting, 'Struct'))) { self.$raise($$($nesting, 'ArgumentError'), "the Struct class has no members")}; return (self.members = ($truthy($a = self.members) ? $a : [])); }, $Struct_members$9.$$arity = 0); Opal.defs(self, '$inherited', $Struct_inherited$10 = function $$inherited(klass) { var $$11, self = this, members = nil; if (self.members == null) self.members = nil; members = self.members; return $send(klass, 'instance_eval', [], ($$11 = function(){var self = $$11.$$s || this; return (self.members = members)}, $$11.$$s = self, $$11.$$arity = 0, $$11)); }, $Struct_inherited$10.$$arity = 1); Opal.def(self, '$initialize', $Struct_initialize$12 = function $$initialize($a) { var $post_args, args, $b, $$13, $$14, self = this, kwargs = nil, extra = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(self.$class().$$keyword_init)) { kwargs = ($truthy($b = args.$last()) ? $b : $hash2([], {})); if ($truthy(($truthy($b = $rb_gt(args.$length(), 1)) ? $b : (args.length === 1 && !kwargs.$$is_hash)))) { self.$raise($$($nesting, 'ArgumentError'), "" + "wrong number of arguments (given " + (args.$length()) + ", expected 0)")}; extra = $rb_minus(kwargs.$keys(), self.$class().$members()); if ($truthy(extra['$any?']())) { self.$raise($$($nesting, 'ArgumentError'), "" + "unknown keywords: " + (extra.$join(", ")))}; return $send(self.$class().$members(), 'each', [], ($$13 = function(name){var self = $$13.$$s || this, $writer = nil; if (name == null) { name = nil; }; $writer = [name, kwargs['$[]'](name)]; $send(self, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$13.$$s = self, $$13.$$arity = 1, $$13)); } else { if ($truthy($rb_gt(args.$length(), self.$class().$members().$length()))) { self.$raise($$($nesting, 'ArgumentError'), "struct size differs")}; return $send(self.$class().$members(), 'each_with_index', [], ($$14 = function(name, index){var self = $$14.$$s || this, $writer = nil; if (name == null) { name = nil; }; if (index == null) { index = nil; }; $writer = [name, args['$[]'](index)]; $send(self, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$14.$$s = self, $$14.$$arity = 2, $$14)); }; }, $Struct_initialize$12.$$arity = -1); Opal.def(self, '$members', $Struct_members$15 = function $$members() { var self = this; return self.$class().$members() }, $Struct_members$15.$$arity = 0); Opal.def(self, '$hash', $Struct_hash$16 = function $$hash() { var self = this; return $$($nesting, 'Hash').$new(self.$$data).$hash() }, $Struct_hash$16.$$arity = 0); Opal.def(self, '$[]', $Struct_$$$17 = function(name) { var self = this; if ($truthy($$($nesting, 'Integer')['$==='](name))) { if ($truthy($rb_lt(name, self.$class().$members().$size()['$-@']()))) { self.$raise($$($nesting, 'IndexError'), "" + "offset " + (name) + " too small for struct(size:" + (self.$class().$members().$size()) + ")")}; if ($truthy($rb_ge(name, self.$class().$members().$size()))) { self.$raise($$($nesting, 'IndexError'), "" + "offset " + (name) + " too large for struct(size:" + (self.$class().$members().$size()) + ")")}; name = self.$class().$members()['$[]'](name); } else if ($truthy($$($nesting, 'String')['$==='](name))) { if(!self.$$data.hasOwnProperty(name)) { self.$raise($$($nesting, 'NameError').$new("" + "no member '" + (name) + "' in struct", name)) } } else { self.$raise($$($nesting, 'TypeError'), "" + "no implicit conversion of " + (name.$class()) + " into Integer") }; name = $$($nesting, 'Opal')['$coerce_to!'](name, $$($nesting, 'String'), "to_str"); return self.$$data[name];; }, $Struct_$$$17.$$arity = 1); Opal.def(self, '$[]=', $Struct_$$$eq$18 = function(name, value) { var self = this; if ($truthy($$($nesting, 'Integer')['$==='](name))) { if ($truthy($rb_lt(name, self.$class().$members().$size()['$-@']()))) { self.$raise($$($nesting, 'IndexError'), "" + "offset " + (name) + " too small for struct(size:" + (self.$class().$members().$size()) + ")")}; if ($truthy($rb_ge(name, self.$class().$members().$size()))) { self.$raise($$($nesting, 'IndexError'), "" + "offset " + (name) + " too large for struct(size:" + (self.$class().$members().$size()) + ")")}; name = self.$class().$members()['$[]'](name); } else if ($truthy($$($nesting, 'String')['$==='](name))) { if ($truthy(self.$class().$members()['$include?'](name.$to_sym()))) { } else { self.$raise($$($nesting, 'NameError').$new("" + "no member '" + (name) + "' in struct", name)) } } else { self.$raise($$($nesting, 'TypeError'), "" + "no implicit conversion of " + (name.$class()) + " into Integer") }; name = $$($nesting, 'Opal')['$coerce_to!'](name, $$($nesting, 'String'), "to_str"); return self.$$data[name] = value;; }, $Struct_$$$eq$18.$$arity = 2); Opal.def(self, '$==', $Struct_$eq_eq$19 = function(other) { var self = this; if ($truthy(other['$instance_of?'](self.$class()))) { } else { return false }; var recursed1 = {}, recursed2 = {}; function _eqeq(struct, other) { var key, a, b; recursed1[(struct).$__id__()] = true; recursed2[(other).$__id__()] = true; for (key in struct.$$data) { a = struct.$$data[key]; b = other.$$data[key]; if ($$($nesting, 'Struct')['$==='](a)) { if (!recursed1.hasOwnProperty((a).$__id__()) || !recursed2.hasOwnProperty((b).$__id__())) { if (!_eqeq(a, b)) { return false; } } } else { if (!(a)['$=='](b)) { return false; } } } return true; } return _eqeq(self, other); ; }, $Struct_$eq_eq$19.$$arity = 1); Opal.def(self, '$eql?', $Struct_eql$ques$20 = function(other) { var self = this; if ($truthy(other['$instance_of?'](self.$class()))) { } else { return false }; var recursed1 = {}, recursed2 = {}; function _eqeq(struct, other) { var key, a, b; recursed1[(struct).$__id__()] = true; recursed2[(other).$__id__()] = true; for (key in struct.$$data) { a = struct.$$data[key]; b = other.$$data[key]; if ($$($nesting, 'Struct')['$==='](a)) { if (!recursed1.hasOwnProperty((a).$__id__()) || !recursed2.hasOwnProperty((b).$__id__())) { if (!_eqeq(a, b)) { return false; } } } else { if (!(a)['$eql?'](b)) { return false; } } } return true; } return _eqeq(self, other); ; }, $Struct_eql$ques$20.$$arity = 1); Opal.def(self, '$each', $Struct_each$21 = function $$each() { var $$22, $$23, $iter = $Struct_each$21.$$p, $yield = $iter || nil, self = this; if ($iter) $Struct_each$21.$$p = null; if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["each"], ($$22 = function(){var self = $$22.$$s || this; return self.$size()}, $$22.$$s = self, $$22.$$arity = 0, $$22)) }; $send(self.$class().$members(), 'each', [], ($$23 = function(name){var self = $$23.$$s || this; if (name == null) { name = nil; }; return Opal.yield1($yield, self['$[]'](name));;}, $$23.$$s = self, $$23.$$arity = 1, $$23)); return self; }, $Struct_each$21.$$arity = 0); Opal.def(self, '$each_pair', $Struct_each_pair$24 = function $$each_pair() { var $$25, $$26, $iter = $Struct_each_pair$24.$$p, $yield = $iter || nil, self = this; if ($iter) $Struct_each_pair$24.$$p = null; if (($yield !== nil)) { } else { return $send(self, 'enum_for', ["each_pair"], ($$25 = function(){var self = $$25.$$s || this; return self.$size()}, $$25.$$s = self, $$25.$$arity = 0, $$25)) }; $send(self.$class().$members(), 'each', [], ($$26 = function(name){var self = $$26.$$s || this; if (name == null) { name = nil; }; return Opal.yield1($yield, [name, self['$[]'](name)]);;}, $$26.$$s = self, $$26.$$arity = 1, $$26)); return self; }, $Struct_each_pair$24.$$arity = 0); Opal.def(self, '$length', $Struct_length$27 = function $$length() { var self = this; return self.$class().$members().$length() }, $Struct_length$27.$$arity = 0); Opal.alias(self, "size", "length"); Opal.def(self, '$to_a', $Struct_to_a$28 = function $$to_a() { var $$29, self = this; return $send(self.$class().$members(), 'map', [], ($$29 = function(name){var self = $$29.$$s || this; if (name == null) { name = nil; }; return self['$[]'](name);}, $$29.$$s = self, $$29.$$arity = 1, $$29)) }, $Struct_to_a$28.$$arity = 0); Opal.alias(self, "values", "to_a"); Opal.def(self, '$inspect', $Struct_inspect$30 = function $$inspect() { var $a, $$31, self = this, result = nil; result = "#"); return result; }, $Struct_inspect$30.$$arity = 0); Opal.alias(self, "to_s", "inspect"); Opal.def(self, '$to_h', $Struct_to_h$32 = function $$to_h() { var $$33, self = this; return $send(self.$class().$members(), 'each_with_object', [$hash2([], {})], ($$33 = function(name, h){var self = $$33.$$s || this, $writer = nil; if (name == null) { name = nil; }; if (h == null) { h = nil; }; $writer = [name, self['$[]'](name)]; $send(h, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$33.$$s = self, $$33.$$arity = 2, $$33)) }, $Struct_to_h$32.$$arity = 0); Opal.def(self, '$values_at', $Struct_values_at$34 = function $$values_at($a) { var $post_args, args, $$35, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; args = $send(args, 'map', [], ($$35 = function(arg){var self = $$35.$$s || this; if (arg == null) { arg = nil; }; return arg.$$is_range ? arg.$to_a() : arg;}, $$35.$$s = self, $$35.$$arity = 1, $$35)).$flatten(); var result = []; for (var i = 0, len = args.length; i < len; i++) { if (!args[i].$$is_number) { self.$raise($$($nesting, 'TypeError'), "" + "no implicit conversion of " + ((args[i]).$class()) + " into Integer") } result.push(self['$[]'](args[i])); } return result; ; }, $Struct_values_at$34.$$arity = -1); return (Opal.def(self, '$dig', $Struct_dig$36 = function $$dig(key, $a) { var $post_args, keys, self = this, item = nil; $post_args = Opal.slice.call(arguments, 1, arguments.length); keys = $post_args;; item = (function() {if ($truthy(key.$$is_string && self.$$data.hasOwnProperty(key))) { return self.$$data[key] || nil; } else { return nil }; return nil; })(); if (item === nil || keys.length === 0) { return item; } ; if ($truthy(item['$respond_to?']("dig"))) { } else { self.$raise($$($nesting, 'TypeError'), "" + (item.$class()) + " does not have #dig method") }; return $send(item, 'dig', Opal.to_a(keys)); }, $Struct_dig$36.$$arity = -2), nil) && 'dig'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/io"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module, $send = Opal.send, $gvars = Opal.gvars, $truthy = Opal.truthy, $writer = nil; Opal.add_stubs(['$attr_accessor', '$size', '$write', '$join', '$map', '$String', '$empty?', '$concat', '$chomp', '$getbyte', '$getc', '$raise', '$new', '$write_proc=', '$-', '$extend']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'IO'); var $nesting = [self].concat($parent_nesting), $IO_tty$ques$1, $IO_closed$ques$2, $IO_write$3, $IO_flush$4; self.$$prototype.tty = self.$$prototype.closed = nil; Opal.const_set($nesting[0], 'SEEK_SET', 0); Opal.const_set($nesting[0], 'SEEK_CUR', 1); Opal.const_set($nesting[0], 'SEEK_END', 2); Opal.def(self, '$tty?', $IO_tty$ques$1 = function() { var self = this; return self.tty }, $IO_tty$ques$1.$$arity = 0); Opal.def(self, '$closed?', $IO_closed$ques$2 = function() { var self = this; return self.closed }, $IO_closed$ques$2.$$arity = 0); self.$attr_accessor("write_proc"); Opal.def(self, '$write', $IO_write$3 = function $$write(string) { var self = this; self.write_proc(string); return string.$size(); }, $IO_write$3.$$arity = 1); self.$attr_accessor("sync", "tty"); Opal.def(self, '$flush', $IO_flush$4 = function $$flush() { var self = this; return nil }, $IO_flush$4.$$arity = 0); (function($base, $parent_nesting) { var self = $module($base, 'Writable'); var $nesting = [self].concat($parent_nesting), $Writable_$lt$lt$5, $Writable_print$6, $Writable_puts$8; Opal.def(self, '$<<', $Writable_$lt$lt$5 = function(string) { var self = this; self.$write(string); return self; }, $Writable_$lt$lt$5.$$arity = 1); Opal.def(self, '$print', $Writable_print$6 = function $$print($a) { var $post_args, args, $$7, self = this; if ($gvars[","] == null) $gvars[","] = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; self.$write($send(args, 'map', [], ($$7 = function(arg){var self = $$7.$$s || this; if (arg == null) { arg = nil; }; return self.$String(arg);}, $$7.$$s = self, $$7.$$arity = 1, $$7)).$join($gvars[","])); return nil; }, $Writable_print$6.$$arity = -1); Opal.def(self, '$puts', $Writable_puts$8 = function $$puts($a) { var $post_args, args, $$9, self = this, newline = nil; if ($gvars["/"] == null) $gvars["/"] = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; newline = $gvars["/"]; if ($truthy(args['$empty?']())) { self.$write($gvars["/"]) } else { self.$write($send(args, 'map', [], ($$9 = function(arg){var self = $$9.$$s || this; if (arg == null) { arg = nil; }; return self.$String(arg).$chomp();}, $$9.$$s = self, $$9.$$arity = 1, $$9)).$concat([nil]).$join(newline)) }; return nil; }, $Writable_puts$8.$$arity = -1); })($nesting[0], $nesting); return (function($base, $parent_nesting) { var self = $module($base, 'Readable'); var $nesting = [self].concat($parent_nesting), $Readable_readbyte$10, $Readable_readchar$11, $Readable_readline$12, $Readable_readpartial$13; Opal.def(self, '$readbyte', $Readable_readbyte$10 = function $$readbyte() { var self = this; return self.$getbyte() }, $Readable_readbyte$10.$$arity = 0); Opal.def(self, '$readchar', $Readable_readchar$11 = function $$readchar() { var self = this; return self.$getc() }, $Readable_readchar$11.$$arity = 0); Opal.def(self, '$readline', $Readable_readline$12 = function $$readline(sep) { var self = this; if ($gvars["/"] == null) $gvars["/"] = nil; if (sep == null) { sep = $gvars["/"]; }; return self.$raise($$($nesting, 'NotImplementedError')); }, $Readable_readline$12.$$arity = -1); Opal.def(self, '$readpartial', $Readable_readpartial$13 = function $$readpartial(integer, outbuf) { var self = this; if (outbuf == null) { outbuf = nil; }; return self.$raise($$($nesting, 'NotImplementedError')); }, $Readable_readpartial$13.$$arity = -2); })($nesting[0], $nesting); })($nesting[0], null, $nesting); Opal.const_set($nesting[0], 'STDERR', ($gvars.stderr = $$($nesting, 'IO').$new())); Opal.const_set($nesting[0], 'STDIN', ($gvars.stdin = $$($nesting, 'IO').$new())); Opal.const_set($nesting[0], 'STDOUT', ($gvars.stdout = $$($nesting, 'IO').$new())); var console = Opal.global.console; $writer = [typeof(process) === 'object' && typeof(process.stdout) === 'object' ? function(s){process.stdout.write(s)} : function(s){console.log(s)}]; $send($$($nesting, 'STDOUT'), 'write_proc=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; $writer = [typeof(process) === 'object' && typeof(process.stderr) === 'object' ? function(s){process.stderr.write(s)} : function(s){console.warn(s)}]; $send($$($nesting, 'STDERR'), 'write_proc=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; $$($nesting, 'STDOUT').$extend($$$($$($nesting, 'IO'), 'Writable')); return $$($nesting, 'STDERR').$extend($$$($$($nesting, 'IO'), 'Writable')); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/main"] = function(Opal) { var $to_s$1, $include$2, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$include']); Opal.defs(self, '$to_s', $to_s$1 = function $$to_s() { var self = this; return "main" }, $to_s$1.$$arity = 0); return (Opal.defs(self, '$include', $include$2 = function $$include(mod) { var self = this; return $$($nesting, 'Object').$include(mod) }, $include$2.$$arity = 1), nil) && 'include'; }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/dir"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$[]']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Dir'); var $nesting = [self].concat($parent_nesting); return (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $chdir$1, $pwd$2, $home$3; Opal.def(self, '$chdir', $chdir$1 = function $$chdir(dir) { var $iter = $chdir$1.$$p, $yield = $iter || nil, self = this, prev_cwd = nil; if ($iter) $chdir$1.$$p = null; return (function() { try { prev_cwd = Opal.current_dir; Opal.current_dir = dir; return Opal.yieldX($yield, []);; } finally { Opal.current_dir = prev_cwd }; })() }, $chdir$1.$$arity = 1); Opal.def(self, '$pwd', $pwd$2 = function $$pwd() { var self = this; return Opal.current_dir || '.'; }, $pwd$2.$$arity = 0); Opal.alias(self, "getwd", "pwd"); return (Opal.def(self, '$home', $home$3 = function $$home() { var $a, self = this; return ($truthy($a = $$($nesting, 'ENV')['$[]']("HOME")) ? $a : ".") }, $home$3.$$arity = 0), nil) && 'home'; })(Opal.get_singleton_class(self), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/file"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $range = Opal.range, $send = Opal.send; Opal.add_stubs(['$respond_to?', '$to_path', '$pwd', '$split', '$sub', '$+', '$unshift', '$join', '$home', '$raise', '$start_with?', '$absolute_path', '$coerce_to!', '$basename', '$empty?', '$rindex', '$[]', '$nil?', '$==', '$-', '$length', '$gsub', '$find', '$=~', '$map', '$each_with_index', '$flatten', '$reject', '$to_proc', '$end_with?']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'File'); var $nesting = [self].concat($parent_nesting), windows_root_rx = nil; Opal.const_set($nesting[0], 'Separator', Opal.const_set($nesting[0], 'SEPARATOR', "/")); Opal.const_set($nesting[0], 'ALT_SEPARATOR', nil); Opal.const_set($nesting[0], 'PATH_SEPARATOR', ":"); Opal.const_set($nesting[0], 'FNM_SYSCASE', 0); windows_root_rx = /^[a-zA-Z]:(?:\\|\/)/; return (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $absolute_path$1, $expand_path$2, $dirname$3, $basename$4, $extname$5, $exist$ques$6, $directory$ques$7, $join$9, $split$12; Opal.def(self, '$absolute_path', $absolute_path$1 = function $$absolute_path(path, basedir) { var $a, self = this, sep = nil, sep_chars = nil, new_parts = nil, path_abs = nil, basedir_abs = nil, parts = nil, leading_sep = nil, abs = nil, new_path = nil; if (basedir == null) { basedir = nil; }; sep = $$($nesting, 'SEPARATOR'); sep_chars = $sep_chars(); new_parts = []; path = (function() {if ($truthy(path['$respond_to?']("to_path"))) { return path.$to_path() } else { return path }; return nil; })(); basedir = ($truthy($a = basedir) ? $a : $$($nesting, 'Dir').$pwd()); path_abs = path.substr(0, sep.length) === sep || windows_root_rx.test(path); basedir_abs = basedir.substr(0, sep.length) === sep || windows_root_rx.test(basedir); if ($truthy(path_abs)) { parts = path.$split(new RegExp("" + "[" + (sep_chars) + "]")); leading_sep = windows_root_rx.test(path) ? '' : path.$sub(new RegExp("" + "^([" + (sep_chars) + "]+).*$"), "\\1"); abs = true; } else { parts = $rb_plus(basedir.$split(new RegExp("" + "[" + (sep_chars) + "]")), path.$split(new RegExp("" + "[" + (sep_chars) + "]"))); leading_sep = windows_root_rx.test(basedir) ? '' : basedir.$sub(new RegExp("" + "^([" + (sep_chars) + "]+).*$"), "\\1"); abs = basedir_abs; }; var part; for (var i = 0, ii = parts.length; i < ii; i++) { part = parts[i]; if ( (part === nil) || (part === '' && ((new_parts.length === 0) || abs)) || (part === '.' && ((new_parts.length === 0) || abs)) ) { continue; } if (part === '..') { new_parts.pop(); } else { new_parts.push(part); } } if (!abs && parts[0] !== '.') { new_parts.$unshift(".") } ; new_path = new_parts.$join(sep); if ($truthy(abs)) { new_path = $rb_plus(leading_sep, new_path)}; return new_path; }, $absolute_path$1.$$arity = -2); Opal.def(self, '$expand_path', $expand_path$2 = function $$expand_path(path, basedir) { var self = this, sep = nil, sep_chars = nil, home = nil, leading_sep = nil, home_path_regexp = nil; if (basedir == null) { basedir = nil; }; sep = $$($nesting, 'SEPARATOR'); sep_chars = $sep_chars(); if ($truthy(path[0] === '~' || (basedir && basedir[0] === '~'))) { home = $$($nesting, 'Dir').$home(); if ($truthy(home)) { } else { self.$raise($$($nesting, 'ArgumentError'), "couldn't find HOME environment -- expanding `~'") }; leading_sep = windows_root_rx.test(home) ? '' : home.$sub(new RegExp("" + "^([" + (sep_chars) + "]+).*$"), "\\1"); if ($truthy(home['$start_with?'](leading_sep))) { } else { self.$raise($$($nesting, 'ArgumentError'), "non-absolute home") }; home = $rb_plus(home, sep); home_path_regexp = new RegExp("" + "^\\~(?:" + (sep) + "|$)"); path = path.$sub(home_path_regexp, home); if ($truthy(basedir)) { basedir = basedir.$sub(home_path_regexp, home)};}; return self.$absolute_path(path, basedir); }, $expand_path$2.$$arity = -2); Opal.alias(self, "realpath", "expand_path"); // Coerce a given path to a path string using #to_path and #to_str function $coerce_to_path(path) { if ($truthy((path)['$respond_to?']("to_path"))) { path = path.$to_path(); } path = $$($nesting, 'Opal')['$coerce_to!'](path, $$($nesting, 'String'), "to_str"); return path; } // Return a RegExp compatible char class function $sep_chars() { if ($$($nesting, 'ALT_SEPARATOR') === nil) { return Opal.escape_regexp($$($nesting, 'SEPARATOR')); } else { return Opal.escape_regexp($rb_plus($$($nesting, 'SEPARATOR'), $$($nesting, 'ALT_SEPARATOR'))); } } ; Opal.def(self, '$dirname', $dirname$3 = function $$dirname(path) { var self = this, sep_chars = nil; sep_chars = $sep_chars(); path = $coerce_to_path(path); var absolute = path.match(new RegExp("" + "^[" + (sep_chars) + "]")); path = path.replace(new RegExp("" + "[" + (sep_chars) + "]+$"), ''); // remove trailing separators path = path.replace(new RegExp("" + "[^" + (sep_chars) + "]+$"), ''); // remove trailing basename path = path.replace(new RegExp("" + "[" + (sep_chars) + "]+$"), ''); // remove final trailing separators if (path === '') { return absolute ? '/' : '.'; } return path; ; }, $dirname$3.$$arity = 1); Opal.def(self, '$basename', $basename$4 = function $$basename(name, suffix) { var self = this, sep_chars = nil; if (suffix == null) { suffix = nil; }; sep_chars = $sep_chars(); name = $coerce_to_path(name); if (name.length == 0) { return name; } if (suffix !== nil) { suffix = $$($nesting, 'Opal')['$coerce_to!'](suffix, $$($nesting, 'String'), "to_str") } else { suffix = null; } name = name.replace(new RegExp("" + "(.)[" + (sep_chars) + "]*$"), '$1'); name = name.replace(new RegExp("" + "^(?:.*[" + (sep_chars) + "])?([^" + (sep_chars) + "]+)$"), '$1'); if (suffix === ".*") { name = name.replace(/\.[^\.]+$/, ''); } else if(suffix !== null) { suffix = Opal.escape_regexp(suffix); name = name.replace(new RegExp("" + (suffix) + "$"), ''); } return name; ; }, $basename$4.$$arity = -2); Opal.def(self, '$extname', $extname$5 = function $$extname(path) { var $a, self = this, filename = nil, last_dot_idx = nil; path = $coerce_to_path(path); filename = self.$basename(path); if ($truthy(filename['$empty?']())) { return ""}; last_dot_idx = filename['$[]']($range(1, -1, false)).$rindex("."); if ($truthy(($truthy($a = last_dot_idx['$nil?']()) ? $a : $rb_plus(last_dot_idx, 1)['$==']($rb_minus(filename.$length(), 1))))) { return "" } else { return filename['$[]'](Opal.Range.$new($rb_plus(last_dot_idx, 1), -1, false)) }; }, $extname$5.$$arity = 1); Opal.def(self, '$exist?', $exist$ques$6 = function(path) { var self = this; return Opal.modules[path] != null }, $exist$ques$6.$$arity = 1); Opal.alias(self, "exists?", "exist?"); Opal.def(self, '$directory?', $directory$ques$7 = function(path) { var $$8, self = this, files = nil, file = nil; files = []; for (var key in Opal.modules) { files.push(key) } ; path = path.$gsub(new RegExp("" + "(^." + ($$($nesting, 'SEPARATOR')) + "+|" + ($$($nesting, 'SEPARATOR')) + "+$)")); file = $send(files, 'find', [], ($$8 = function(f){var self = $$8.$$s || this; if (f == null) { f = nil; }; return f['$=~'](new RegExp("" + "^" + (path)));}, $$8.$$s = self, $$8.$$arity = 1, $$8)); return file; }, $directory$ques$7.$$arity = 1); Opal.def(self, '$join', $join$9 = function $$join($a) { var $post_args, paths, $$10, $$11, self = this, result = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); paths = $post_args;; if ($truthy(paths['$empty?']())) { return ""}; result = ""; paths = $send(paths.$flatten().$each_with_index(), 'map', [], ($$10 = function(item, index){var self = $$10.$$s || this, $b; if (item == null) { item = nil; }; if (index == null) { index = nil; }; if ($truthy((($b = index['$=='](0)) ? item['$empty?']() : index['$=='](0)))) { return $$($nesting, 'SEPARATOR') } else if ($truthy((($b = paths.$length()['$==']($rb_plus(index, 1))) ? item['$empty?']() : paths.$length()['$==']($rb_plus(index, 1))))) { return $$($nesting, 'SEPARATOR') } else { return item };}, $$10.$$s = self, $$10.$$arity = 2, $$10)); paths = $send(paths, 'reject', [], "empty?".$to_proc()); $send(paths, 'each_with_index', [], ($$11 = function(item, index){var self = $$11.$$s || this, $b, next_item = nil; if (item == null) { item = nil; }; if (index == null) { index = nil; }; next_item = paths['$[]']($rb_plus(index, 1)); if ($truthy(next_item['$nil?']())) { return (result = "" + (result) + (item)) } else { if ($truthy(($truthy($b = item['$end_with?']($$($nesting, 'SEPARATOR'))) ? next_item['$start_with?']($$($nesting, 'SEPARATOR')) : $b))) { item = item.$sub(new RegExp("" + ($$($nesting, 'SEPARATOR')) + "+$"), "")}; return (result = (function() {if ($truthy(($truthy($b = item['$end_with?']($$($nesting, 'SEPARATOR'))) ? $b : next_item['$start_with?']($$($nesting, 'SEPARATOR'))))) { return "" + (result) + (item) } else { return "" + (result) + (item) + ($$($nesting, 'SEPARATOR')) }; return nil; })()); };}, $$11.$$s = self, $$11.$$arity = 2, $$11)); return result; }, $join$9.$$arity = -1); return (Opal.def(self, '$split', $split$12 = function $$split(path) { var self = this; return path.$split($$($nesting, 'SEPARATOR')) }, $split$12.$$arity = 1), nil) && 'split'; })(Opal.get_singleton_class(self), $nesting); })($nesting[0], $$($nesting, 'IO'), $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/process"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$const_set', '$size', '$<<', '$__register_clock__', '$to_f', '$now', '$new', '$[]', '$raise']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Process'); var $nesting = [self].concat($parent_nesting), $Process___register_clock__$1, $Process_pid$2, $Process_times$3, $Process_clock_gettime$4, monotonic = nil; self.__clocks__ = []; Opal.defs(self, '$__register_clock__', $Process___register_clock__$1 = function $$__register_clock__(name, func) { var self = this; if (self.__clocks__ == null) self.__clocks__ = nil; self.$const_set(name, self.__clocks__.$size()); return self.__clocks__['$<<'](func); }, $Process___register_clock__$1.$$arity = 2); self.$__register_clock__("CLOCK_REALTIME", function() { return Date.now() }); monotonic = false; if (Opal.global.performance) { monotonic = function() { return performance.now() }; } else if (Opal.global.process && process.hrtime) { // let now be the base to get smaller numbers var hrtime_base = process.hrtime(); monotonic = function() { var hrtime = process.hrtime(hrtime_base); var us = (hrtime[1] / 1000) | 0; // cut below microsecs; return ((hrtime[0] * 1000) + (us / 1000)); }; } ; if ($truthy(monotonic)) { self.$__register_clock__("CLOCK_MONOTONIC", monotonic)}; Opal.defs(self, '$pid', $Process_pid$2 = function $$pid() { var self = this; return 0 }, $Process_pid$2.$$arity = 0); Opal.defs(self, '$times', $Process_times$3 = function $$times() { var self = this, t = nil; t = $$($nesting, 'Time').$now().$to_f(); return $$$($$($nesting, 'Benchmark'), 'Tms').$new(t, t, t, t, t); }, $Process_times$3.$$arity = 0); return (Opal.defs(self, '$clock_gettime', $Process_clock_gettime$4 = function $$clock_gettime(clock_id, unit) { var $a, self = this, clock = nil; if (self.__clocks__ == null) self.__clocks__ = nil; if (unit == null) { unit = "float_second"; }; ($truthy($a = (clock = self.__clocks__['$[]'](clock_id))) ? $a : self.$raise($$$($$($nesting, 'Errno'), 'EINVAL'), "" + "clock_gettime(" + (clock_id) + ") " + (self.__clocks__['$[]'](clock_id)))); var ms = clock(); switch (unit) { case 'float_second': return (ms / 1000); // number of seconds as a float (default) case 'float_millisecond': return (ms / 1); // number of milliseconds as a float case 'float_microsecond': return (ms * 1000); // number of microseconds as a float case 'second': return ((ms / 1000) | 0); // number of seconds as an integer case 'millisecond': return ((ms / 1) | 0); // number of milliseconds as an integer case 'microsecond': return ((ms * 1000) | 0); // number of microseconds as an integer case 'nanosecond': return ((ms * 1000000) | 0); // number of nanoseconds as an integer default: self.$raise($$($nesting, 'ArgumentError'), "" + "unexpected unit: " + (unit)) } ; }, $Process_clock_gettime$4.$$arity = -2), nil) && 'clock_gettime'; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Signal'); var $nesting = [self].concat($parent_nesting), $Signal_trap$5; return (Opal.defs(self, '$trap', $Signal_trap$5 = function $$trap($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $Signal_trap$5.$$arity = -1), nil) && 'trap' })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'GC'); var $nesting = [self].concat($parent_nesting), $GC_start$6; return (Opal.defs(self, '$start', $GC_start$6 = function $$start() { var self = this; return nil }, $GC_start$6.$$arity = 0), nil) && 'start' })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/random"] = function(Opal) { function $rb_lt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs < rhs : lhs['$<'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$new_seed', '$coerce_to!', '$reseed', '$rand', '$seed', '$<', '$raise', '$encode', '$join', '$new', '$chr', '$===', '$==', '$state', '$const_defined?', '$const_set']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Random'); var $nesting = [self].concat($parent_nesting), $Random_initialize$1, $Random_reseed$2, $Random_new_seed$3, $Random_rand$4, $Random_srand$5, $Random_urandom$6, $Random_$eq_eq$8, $Random_bytes$9, $Random_rand$11, $Random_generator$eq$12; self.$attr_reader("seed", "state"); Opal.def(self, '$initialize', $Random_initialize$1 = function $$initialize(seed) { var self = this; if (seed == null) { seed = $$($nesting, 'Random').$new_seed(); }; seed = $$($nesting, 'Opal')['$coerce_to!'](seed, $$($nesting, 'Integer'), "to_int"); self.state = seed; return self.$reseed(seed); }, $Random_initialize$1.$$arity = -1); Opal.def(self, '$reseed', $Random_reseed$2 = function $$reseed(seed) { var self = this; self.seed = seed; return self.$rng = Opal.$$rand.reseed(seed);; }, $Random_reseed$2.$$arity = 1); Opal.defs(self, '$new_seed', $Random_new_seed$3 = function $$new_seed() { var self = this; return Opal.$$rand.new_seed(); }, $Random_new_seed$3.$$arity = 0); Opal.defs(self, '$rand', $Random_rand$4 = function $$rand(limit) { var self = this; ; return $$($nesting, 'DEFAULT').$rand(limit); }, $Random_rand$4.$$arity = -1); Opal.defs(self, '$srand', $Random_srand$5 = function $$srand(n) { var self = this, previous_seed = nil; if (n == null) { n = $$($nesting, 'Random').$new_seed(); }; n = $$($nesting, 'Opal')['$coerce_to!'](n, $$($nesting, 'Integer'), "to_int"); previous_seed = $$($nesting, 'DEFAULT').$seed(); $$($nesting, 'DEFAULT').$reseed(n); return previous_seed; }, $Random_srand$5.$$arity = -1); Opal.defs(self, '$urandom', $Random_urandom$6 = function $$urandom(size) { var $$7, self = this; size = $$($nesting, 'Opal')['$coerce_to!'](size, $$($nesting, 'Integer'), "to_int"); if ($truthy($rb_lt(size, 0))) { self.$raise($$($nesting, 'ArgumentError'), "negative string size (or size too big)")}; return $send($$($nesting, 'Array'), 'new', [size], ($$7 = function(){var self = $$7.$$s || this; return self.$rand(255).$chr()}, $$7.$$s = self, $$7.$$arity = 0, $$7)).$join().$encode("ASCII-8BIT"); }, $Random_urandom$6.$$arity = 1); Opal.def(self, '$==', $Random_$eq_eq$8 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Random')['$==='](other))) { } else { return false }; return (($a = self.$seed()['$=='](other.$seed())) ? self.$state()['$=='](other.$state()) : self.$seed()['$=='](other.$seed())); }, $Random_$eq_eq$8.$$arity = 1); Opal.def(self, '$bytes', $Random_bytes$9 = function $$bytes(length) { var $$10, self = this; length = $$($nesting, 'Opal')['$coerce_to!'](length, $$($nesting, 'Integer'), "to_int"); return $send($$($nesting, 'Array'), 'new', [length], ($$10 = function(){var self = $$10.$$s || this; return self.$rand(255).$chr()}, $$10.$$s = self, $$10.$$arity = 0, $$10)).$join().$encode("ASCII-8BIT"); }, $Random_bytes$9.$$arity = 1); Opal.def(self, '$rand', $Random_rand$11 = function $$rand(limit) { var self = this; ; function randomFloat() { self.state++; return Opal.$$rand.rand(self.$rng); } function randomInt() { return Math.floor(randomFloat() * limit); } function randomRange() { var min = limit.begin, max = limit.end; if (min === nil || max === nil) { return nil; } var length = max - min; if (length < 0) { return nil; } if (length === 0) { return min; } if (max % 1 === 0 && min % 1 === 0 && !limit.excl) { length++; } return self.$rand(length) + min; } if (limit == null) { return randomFloat(); } else if (limit.$$is_range) { return randomRange(); } else if (limit.$$is_number) { if (limit <= 0) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid argument - " + (limit)) } if (limit % 1 === 0) { // integer return randomInt(); } else { return randomFloat() * limit; } } else { limit = $$($nesting, 'Opal')['$coerce_to!'](limit, $$($nesting, 'Integer'), "to_int"); if (limit <= 0) { self.$raise($$($nesting, 'ArgumentError'), "" + "invalid argument - " + (limit)) } return randomInt(); } ; }, $Random_rand$11.$$arity = -1); return (Opal.defs(self, '$generator=', $Random_generator$eq$12 = function(generator) { var self = this; Opal.$$rand = generator; if ($truthy(self['$const_defined?']("DEFAULT"))) { return $$($nesting, 'DEFAULT').$reseed() } else { return self.$const_set("DEFAULT", self.$new(self.$new_seed())) }; }, $Random_generator$eq$12.$$arity = 1), nil) && 'generator='; })($nesting[0], null, $nesting) }; /* This is based on an adaptation of Makoto Matsumoto and Takuji Nishimura's code done by Sean McCullough and Dave Heitzman , subsequently readapted from an updated version of ruby's random.c (rev c38a183032a7826df1adabd8aa0725c713d53e1c). The original copyright notice from random.c follows. This is based on trimmed version of MT19937. To get the original version, contact . The original copyright notice follows. A C-program for MT19937, with initialization improved 2002/2/10. Coded by Takuji Nishimura and Makoto Matsumoto. This is a faster version by taking Shawn Cokus's optimization, Matthe Bellew's simplification, Isaku Wada's real version. Before using, initialize the state by using init_genrand(mt, seed) or init_by_array(mt, init_key, key_length). Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Any feedback is very welcome. http://www.math.keio.ac.jp/matumoto/emt.html email: matumoto@math.keio.ac.jp */ var MersenneTwister = (function() { /* Period parameters */ var N = 624; var M = 397; var MATRIX_A = 0x9908b0df; /* constant vector a */ var UMASK = 0x80000000; /* most significant w-r bits */ var LMASK = 0x7fffffff; /* least significant r bits */ var MIXBITS = function(u,v) { return ( ((u) & UMASK) | ((v) & LMASK) ); }; var TWIST = function(u,v) { return (MIXBITS((u),(v)) >>> 1) ^ ((v & 0x1) ? MATRIX_A : 0x0); }; function init(s) { var mt = {left: 0, next: N, state: new Array(N)}; init_genrand(mt, s); return mt; } /* initializes mt[N] with a seed */ function init_genrand(mt, s) { var j, i; mt.state[0] = s >>> 0; for (j=1; j> 30) >>> 0)) + j); /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* In the previous versions, MSBs of the seed affect */ /* only MSBs of the array state[]. */ /* 2002/01/09 modified by Makoto Matsumoto */ mt.state[j] &= 0xffffffff; /* for >32 bit machines */ } mt.left = 1; mt.next = N; } /* generate N words at one time */ function next_state(mt) { var p = 0, _p = mt.state; var j; mt.left = N; mt.next = 0; for (j=N-M+1; --j; p++) _p[p] = _p[p+(M)] ^ TWIST(_p[p+(0)], _p[p+(1)]); for (j=M; --j; p++) _p[p] = _p[p+(M-N)] ^ TWIST(_p[p+(0)], _p[p+(1)]); _p[p] = _p[p+(M-N)] ^ TWIST(_p[p+(0)], _p[0]); } /* generates a random number on [0,0xffffffff]-interval */ function genrand_int32(mt) { /* mt must be initialized */ var y; if (--mt.left <= 0) next_state(mt); y = mt.state[mt.next++]; /* Tempering */ y ^= (y >>> 11); y ^= (y << 7) & 0x9d2c5680; y ^= (y << 15) & 0xefc60000; y ^= (y >>> 18); return y >>> 0; } function int_pair_to_real_exclusive(a, b) { a >>>= 5; b >>>= 6; return(a*67108864.0+b)*(1.0/9007199254740992.0); } // generates a random number on [0,1) with 53-bit resolution function genrand_real(mt) { /* mt must be initialized */ var a = genrand_int32(mt), b = genrand_int32(mt); return int_pair_to_real_exclusive(a, b); } return { genrand_real: genrand_real, init: init }; })(); Opal.loaded(["corelib/random/MersenneTwister.js"]); /* Generated by Opal 1.0.3 */ Opal.modules["corelib/random/mersenne_twister"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$require', '$generator=', '$-']); self.$require("corelib/random/MersenneTwister"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Random'); var $nesting = [self].concat($parent_nesting), $writer = nil; var MAX_INT = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; Opal.const_set($nesting[0], 'MERSENNE_TWISTER_GENERATOR', { new_seed: function() { return Math.round(Math.random() * MAX_INT); }, reseed: function(seed) { return MersenneTwister.init(seed); }, rand: function(mt) { return MersenneTwister.genrand_real(mt); } }); $writer = [$$($nesting, 'MERSENNE_TWISTER_GENERATOR')]; $send(self, 'generator=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["corelib/unsupported"] = function(Opal) { var $public$35, $private$36, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module; Opal.add_stubs(['$raise', '$warn', '$%']); var warnings = {}; function handle_unsupported_feature(message) { switch (Opal.config.unsupported_features_severity) { case 'error': $$($nesting, 'Kernel').$raise($$($nesting, 'NotImplementedError'), message) break; case 'warning': warn(message) break; default: // ignore // noop } } function warn(string) { if (warnings[string]) { return; } warnings[string] = true; self.$warn(string); } ; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String_$lt$lt$1, $String_capitalize$excl$2, $String_chomp$excl$3, $String_chop$excl$4, $String_downcase$excl$5, $String_gsub$excl$6, $String_lstrip$excl$7, $String_next$excl$8, $String_reverse$excl$9, $String_slice$excl$10, $String_squeeze$excl$11, $String_strip$excl$12, $String_sub$excl$13, $String_succ$excl$14, $String_swapcase$excl$15, $String_tr$excl$16, $String_tr_s$excl$17, $String_upcase$excl$18, $String_prepend$19, $String_$$$eq$20, $String_clear$21, $String_encode$excl$22, $String_unicode_normalize$excl$23; var ERROR = "String#%s not supported. Mutable String methods are not supported in Opal."; Opal.def(self, '$<<', $String_$lt$lt$1 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("<<")); }, $String_$lt$lt$1.$$arity = -1); Opal.def(self, '$capitalize!', $String_capitalize$excl$2 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("capitalize!")); }, $String_capitalize$excl$2.$$arity = -1); Opal.def(self, '$chomp!', $String_chomp$excl$3 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("chomp!")); }, $String_chomp$excl$3.$$arity = -1); Opal.def(self, '$chop!', $String_chop$excl$4 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("chop!")); }, $String_chop$excl$4.$$arity = -1); Opal.def(self, '$downcase!', $String_downcase$excl$5 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("downcase!")); }, $String_downcase$excl$5.$$arity = -1); Opal.def(self, '$gsub!', $String_gsub$excl$6 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("gsub!")); }, $String_gsub$excl$6.$$arity = -1); Opal.def(self, '$lstrip!', $String_lstrip$excl$7 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("lstrip!")); }, $String_lstrip$excl$7.$$arity = -1); Opal.def(self, '$next!', $String_next$excl$8 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("next!")); }, $String_next$excl$8.$$arity = -1); Opal.def(self, '$reverse!', $String_reverse$excl$9 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("reverse!")); }, $String_reverse$excl$9.$$arity = -1); Opal.def(self, '$slice!', $String_slice$excl$10 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("slice!")); }, $String_slice$excl$10.$$arity = -1); Opal.def(self, '$squeeze!', $String_squeeze$excl$11 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("squeeze!")); }, $String_squeeze$excl$11.$$arity = -1); Opal.def(self, '$strip!', $String_strip$excl$12 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("strip!")); }, $String_strip$excl$12.$$arity = -1); Opal.def(self, '$sub!', $String_sub$excl$13 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("sub!")); }, $String_sub$excl$13.$$arity = -1); Opal.def(self, '$succ!', $String_succ$excl$14 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("succ!")); }, $String_succ$excl$14.$$arity = -1); Opal.def(self, '$swapcase!', $String_swapcase$excl$15 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("swapcase!")); }, $String_swapcase$excl$15.$$arity = -1); Opal.def(self, '$tr!', $String_tr$excl$16 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("tr!")); }, $String_tr$excl$16.$$arity = -1); Opal.def(self, '$tr_s!', $String_tr_s$excl$17 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("tr_s!")); }, $String_tr_s$excl$17.$$arity = -1); Opal.def(self, '$upcase!', $String_upcase$excl$18 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("upcase!")); }, $String_upcase$excl$18.$$arity = -1); Opal.def(self, '$prepend', $String_prepend$19 = function $$prepend($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("prepend")); }, $String_prepend$19.$$arity = -1); Opal.def(self, '$[]=', $String_$$$eq$20 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("[]=")); }, $String_$$$eq$20.$$arity = -1); Opal.def(self, '$clear', $String_clear$21 = function $$clear($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("clear")); }, $String_clear$21.$$arity = -1); Opal.def(self, '$encode!', $String_encode$excl$22 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("encode!")); }, $String_encode$excl$22.$$arity = -1); return (Opal.def(self, '$unicode_normalize!', $String_unicode_normalize$excl$23 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), (ERROR)['$%']("unicode_normalize!")); }, $String_unicode_normalize$excl$23.$$arity = -1), nil) && 'unicode_normalize!'; })($nesting[0], null, $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_freeze$24, $Kernel_frozen$ques$25; var ERROR = "Object freezing is not supported by Opal"; Opal.def(self, '$freeze', $Kernel_freeze$24 = function $$freeze() { var self = this; handle_unsupported_feature(ERROR); return self; }, $Kernel_freeze$24.$$arity = 0); Opal.def(self, '$frozen?', $Kernel_frozen$ques$25 = function() { var self = this; handle_unsupported_feature(ERROR); return false; }, $Kernel_frozen$ques$25.$$arity = 0); })($nesting[0], $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_taint$26, $Kernel_untaint$27, $Kernel_tainted$ques$28; var ERROR = "Object tainting is not supported by Opal"; Opal.def(self, '$taint', $Kernel_taint$26 = function $$taint() { var self = this; handle_unsupported_feature(ERROR); return self; }, $Kernel_taint$26.$$arity = 0); Opal.def(self, '$untaint', $Kernel_untaint$27 = function $$untaint() { var self = this; handle_unsupported_feature(ERROR); return self; }, $Kernel_untaint$27.$$arity = 0); Opal.def(self, '$tainted?', $Kernel_tainted$ques$28 = function() { var self = this; handle_unsupported_feature(ERROR); return false; }, $Kernel_tainted$ques$28.$$arity = 0); })($nesting[0], $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Module'); var $nesting = [self].concat($parent_nesting), $Module_public$29, $Module_private_class_method$30, $Module_private_method_defined$ques$31, $Module_private_constant$32; Opal.def(self, '$public', $Module_public$29 = function($a) { var $post_args, methods, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); methods = $post_args;; if (methods.length === 0) { self.$$module_function = false; } return nil; ; }, $Module_public$29.$$arity = -1); Opal.alias(self, "private", "public"); Opal.alias(self, "protected", "public"); Opal.alias(self, "nesting", "public"); Opal.def(self, '$private_class_method', $Module_private_class_method$30 = function $$private_class_method($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self; }, $Module_private_class_method$30.$$arity = -1); Opal.alias(self, "public_class_method", "private_class_method"); Opal.def(self, '$private_method_defined?', $Module_private_method_defined$ques$31 = function(obj) { var self = this; return false }, $Module_private_method_defined$ques$31.$$arity = 1); Opal.def(self, '$private_constant', $Module_private_constant$32 = function $$private_constant($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $Module_private_constant$32.$$arity = -1); Opal.alias(self, "protected_method_defined?", "private_method_defined?"); Opal.alias(self, "public_instance_methods", "instance_methods"); Opal.alias(self, "public_instance_method", "instance_method"); return Opal.alias(self, "public_method_defined?", "method_defined?"); })($nesting[0], null, $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_private_methods$33; Opal.def(self, '$private_methods', $Kernel_private_methods$33 = function $$private_methods($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return []; }, $Kernel_private_methods$33.$$arity = -1); Opal.alias(self, "private_instance_methods", "private_methods"); })($nesting[0], $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_eval$34; Opal.def(self, '$eval', $Kernel_eval$34 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError'), "" + "To use Kernel#eval, you must first require 'opal-parser'. " + ("" + "See https://github.com/opal/opal/blob/" + ($$($nesting, 'RUBY_ENGINE_VERSION')) + "/docs/opal_parser.md for details.")); }, $Kernel_eval$34.$$arity = -1) })($nesting[0], $nesting); Opal.defs(self, '$public', $public$35 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $public$35.$$arity = -1); return (Opal.defs(self, '$private', $private$36 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return nil; }, $private$36.$$arity = -1), nil) && 'private'; }; /* Generated by Opal 1.0.3 */ Opal.modules["opal"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$require']); self.$require("opal/base"); self.$require("opal/mini"); self.$require("corelib/kernel/format"); self.$require("corelib/string/encoding"); self.$require("corelib/math"); self.$require("corelib/complex"); self.$require("corelib/rational"); self.$require("corelib/time"); self.$require("corelib/struct"); self.$require("corelib/io"); self.$require("corelib/main"); self.$require("corelib/dir"); self.$require("corelib/file"); self.$require("corelib/process"); self.$require("corelib/random"); self.$require("corelib/random/mersenne_twister.js"); return self.$require("corelib/unsupported"); }; /* Generated by Opal 1.0.3 */ Opal.modules["native"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_ge(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy, $send = Opal.send, $hash2 = Opal.hash2, $range = Opal.range, $klass = Opal.klass, $gvars = Opal.gvars; Opal.add_stubs(['$try_convert', '$native?', '$respond_to?', '$to_n', '$raise', '$inspect', '$Native', '$proc', '$map!', '$end_with?', '$define_method', '$[]', '$convert', '$call', '$to_proc', '$new', '$each', '$native_reader', '$native_writer', '$extend', '$warn', '$include', '$is_a?', '$map', '$to_a', '$_Array', '$method_missing', '$bind', '$instance_method', '$slice', '$-', '$length', '$[]=', '$enum_for', '$===', '$>=', '$<<', '$each_pair', '$_initialize', '$name', '$native_module']); (function($base, $parent_nesting) { var self = $module($base, 'Native'); var $nesting = [self].concat($parent_nesting), $Native_is_a$ques$1, $Native_try_convert$2, $Native_convert$3, $Native_call$4, $Native_proc$5, $Native_included$22; Opal.defs(self, '$is_a?', $Native_is_a$ques$1 = function(object, klass) { var self = this; try { return object instanceof self.$try_convert(klass); } catch (e) { return false; } }, $Native_is_a$ques$1.$$arity = 2); Opal.defs(self, '$try_convert', $Native_try_convert$2 = function $$try_convert(value, default$) { var self = this; if (default$ == null) { default$ = nil; }; if (self['$native?'](value)) { return value; } else if (value['$respond_to?']("to_n")) { return value.$to_n(); } else { return default$; } ; }, $Native_try_convert$2.$$arity = -2); Opal.defs(self, '$convert', $Native_convert$3 = function $$convert(value) { var self = this; if (self['$native?'](value)) { return value; } else if (value['$respond_to?']("to_n")) { return value.$to_n(); } else { self.$raise($$($nesting, 'ArgumentError'), "" + (value.$inspect()) + " isn't native"); } }, $Native_convert$3.$$arity = 1); Opal.defs(self, '$call', $Native_call$4 = function $$call(obj, key, $a) { var $iter = $Native_call$4.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Native_call$4.$$p = null; if ($iter) $Native_call$4.$$p = null;; $post_args = Opal.slice.call(arguments, 2, arguments.length); args = $post_args;; var prop = obj[key]; if (prop instanceof Function) { var converted = new Array(args.length); for (var i = 0, l = args.length; i < l; i++) { var item = args[i], conv = self.$try_convert(item); converted[i] = conv === nil ? item : conv; } if (block !== nil) { converted.push(block); } return self.$Native(prop.apply(obj, converted)); } else { return self.$Native(prop); } ; }, $Native_call$4.$$arity = -3); Opal.defs(self, '$proc', $Native_proc$5 = function $$proc() { var $iter = $Native_proc$5.$$p, block = $iter || nil, $$6, self = this; if ($iter) $Native_proc$5.$$p = null; if ($iter) $Native_proc$5.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'LocalJumpError'), "no block given") }; return $send($$$('::', 'Kernel'), 'proc', [], ($$6 = function($a){var self = $$6.$$s || this, $post_args, args, $$7, instance = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; $send(args, 'map!', [], ($$7 = function(arg){var self = $$7.$$s || this; if (arg == null) { arg = nil; }; return self.$Native(arg);}, $$7.$$s = self, $$7.$$arity = 1, $$7)); instance = self.$Native(this); // if global is current scope, run the block in the scope it was defined if (this === Opal.global) { return block.apply(self, args); } var self_ = block.$$s; block.$$s = null; try { return block.apply(instance, args); } finally { block.$$s = self_; } ;}, $$6.$$s = self, $$6.$$arity = -1, $$6)); }, $Native_proc$5.$$arity = 0); (function($base, $parent_nesting) { var self = $module($base, 'Helpers'); var $nesting = [self].concat($parent_nesting), $Helpers_alias_native$8, $Helpers_native_reader$12, $Helpers_native_writer$15, $Helpers_native_accessor$18; Opal.def(self, '$alias_native', $Helpers_alias_native$8 = function $$alias_native(new$, $a, $b) { var $post_args, $kwargs, old, as, $$9, $$10, $$11, $iter = $Helpers_alias_native$8.$$p, $yield = $iter || nil, self = this; if ($iter) $Helpers_alias_native$8.$$p = null; $post_args = Opal.slice.call(arguments, 1, arguments.length); $kwargs = Opal.extract_kwargs($post_args); if ($kwargs == null) { $kwargs = $hash2([], {}); } else if (!$kwargs.$$is_hash) { throw Opal.ArgumentError.$new('expected kwargs'); }; if ($post_args.length > 0) { old = $post_args[0]; $post_args.splice(0, 1); } if (old == null) { old = new$; }; as = $kwargs.$$smap["as"]; if (as == null) { as = nil }; if ($truthy(old['$end_with?']("="))) { return $send(self, 'define_method', [new$], ($$9 = function(value){var self = $$9.$$s || this; if (self["native"] == null) self["native"] = nil; if (value == null) { value = nil; }; self["native"][old['$[]']($range(0, -2, false))] = $$($nesting, 'Native').$convert(value); return value;}, $$9.$$s = self, $$9.$$arity = 1, $$9)) } else if ($truthy(as)) { return $send(self, 'define_method', [new$], ($$10 = function($c){var self = $$10.$$s || this, $iter = $$10.$$p, block = $iter || nil, $post_args, args, value = nil; if (self["native"] == null) self["native"] = nil; if ($iter) $$10.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; value = $send($$($nesting, 'Native'), 'call', [self["native"], old].concat(Opal.to_a(args)), block.$to_proc()); if ($truthy(value)) { return as.$new(value.$to_n()) } else { return nil };}, $$10.$$s = self, $$10.$$arity = -1, $$10)) } else { return $send(self, 'define_method', [new$], ($$11 = function($c){var self = $$11.$$s || this, $iter = $$11.$$p, block = $iter || nil, $post_args, args; if (self["native"] == null) self["native"] = nil; if ($iter) $$11.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send($$($nesting, 'Native'), 'call', [self["native"], old].concat(Opal.to_a(args)), block.$to_proc());}, $$11.$$s = self, $$11.$$arity = -1, $$11)) }; }, $Helpers_alias_native$8.$$arity = -2); Opal.def(self, '$native_reader', $Helpers_native_reader$12 = function $$native_reader($a) { var $post_args, names, $$13, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; return $send(names, 'each', [], ($$13 = function(name){var self = $$13.$$s || this, $$14; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$14 = function(){var self = $$14.$$s || this; if (self["native"] == null) self["native"] = nil; return self.$Native(self["native"][name])}, $$14.$$s = self, $$14.$$arity = 0, $$14));}, $$13.$$s = self, $$13.$$arity = 1, $$13)); }, $Helpers_native_reader$12.$$arity = -1); Opal.def(self, '$native_writer', $Helpers_native_writer$15 = function $$native_writer($a) { var $post_args, names, $$16, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; return $send(names, 'each', [], ($$16 = function(name){var self = $$16.$$s || this, $$17; if (name == null) { name = nil; }; return $send(self, 'define_method', ["" + (name) + "="], ($$17 = function(value){var self = $$17.$$s || this; if (self["native"] == null) self["native"] = nil; if (value == null) { value = nil; }; return self.$Native(self["native"][name] = value);}, $$17.$$s = self, $$17.$$arity = 1, $$17));}, $$16.$$s = self, $$16.$$arity = 1, $$16)); }, $Helpers_native_writer$15.$$arity = -1); Opal.def(self, '$native_accessor', $Helpers_native_accessor$18 = function $$native_accessor($a) { var $post_args, names, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; $send(self, 'native_reader', Opal.to_a(names)); return $send(self, 'native_writer', Opal.to_a(names)); }, $Helpers_native_accessor$18.$$arity = -1); })($nesting[0], $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Wrapper'); var $nesting = [self].concat($parent_nesting), $Wrapper_initialize$19, $Wrapper_to_n$20, $Wrapper_included$21; Opal.def(self, '$initialize', $Wrapper_initialize$19 = function $$initialize(native$) { var self = this; if ($truthy($$$('::', 'Kernel')['$native?'](native$))) { } else { $$$('::', 'Kernel').$raise($$($nesting, 'ArgumentError'), "" + (native$.$inspect()) + " isn't native") }; return (self["native"] = native$); }, $Wrapper_initialize$19.$$arity = 1); Opal.def(self, '$to_n', $Wrapper_to_n$20 = function $$to_n() { var self = this; if (self["native"] == null) self["native"] = nil; return self["native"] }, $Wrapper_to_n$20.$$arity = 0); Opal.defs(self, '$included', $Wrapper_included$21 = function $$included(klass) { var self = this; return klass.$extend($$($nesting, 'Helpers')) }, $Wrapper_included$21.$$arity = 1); })($nesting[0], $nesting); Opal.defs(self, '$included', $Native_included$22 = function $$included(base) { var self = this; self.$warn("Including ::Native is deprecated. Please include Native::Wrapper instead."); return base.$include($$($nesting, 'Wrapper')); }, $Native_included$22.$$arity = 1); })($nesting[0], $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_native$ques$23, $Kernel_Native$24, $Kernel_Array$27; Opal.def(self, '$native?', $Kernel_native$ques$23 = function(value) { var self = this; return value == null || !value.$$class; }, $Kernel_native$ques$23.$$arity = 1); Opal.def(self, '$Native', $Kernel_Native$24 = function $$Native(obj) { var $$25, $$26, $iter = $Kernel_Native$24.$$p, $yield = $iter || nil, self = this; if ($iter) $Kernel_Native$24.$$p = null; if ($truthy(obj == null)) { return nil } else if ($truthy(self['$native?'](obj))) { return $$$($$($nesting, 'Native'), 'Object').$new(obj) } else if ($truthy(obj['$is_a?']($$($nesting, 'Array')))) { return $send(obj, 'map', [], ($$25 = function(o){var self = $$25.$$s || this; if (o == null) { o = nil; }; return self.$Native(o);}, $$25.$$s = self, $$25.$$arity = 1, $$25)) } else if ($truthy(obj['$is_a?']($$($nesting, 'Proc')))) { return $send(self, 'proc', [], ($$26 = function($a){var self = $$26.$$s || this, $iter = $$26.$$p, block = $iter || nil, $post_args, args; if ($iter) $$26.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return self.$Native($send(obj, 'call', Opal.to_a(args), block.$to_proc()));}, $$26.$$s = self, $$26.$$arity = -1, $$26)) } else { return obj } }, $Kernel_Native$24.$$arity = 1); Opal.alias(self, "_Array", "Array"); Opal.def(self, '$Array', $Kernel_Array$27 = function $$Array(object, $a) { var $iter = $Kernel_Array$27.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Kernel_Array$27.$$p = null; if ($iter) $Kernel_Array$27.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(self['$native?'](object))) { return $send($$$($$($nesting, 'Native'), 'Array'), 'new', [object].concat(Opal.to_a(args)), block.$to_proc()).$to_a()}; return self.$_Array(object); }, $Kernel_Array$27.$$arity = -2); })($nesting[0], $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Object'); var $nesting = [self].concat($parent_nesting), $Object_$eq_eq$28, $Object_has_key$ques$29, $Object_each$30, $Object_$$$31, $Object_$$$eq$32, $Object_merge$excl$33, $Object_respond_to$ques$34, $Object_respond_to_missing$ques$35, $Object_method_missing$36, $Object_nil$ques$37, $Object_is_a$ques$38, $Object_instance_of$ques$39, $Object_class$40, $Object_to_a$41, $Object_inspect$42; self.$$prototype["native"] = nil; self.$include($$$($$$('::', 'Native'), 'Wrapper')); Opal.def(self, '$==', $Object_$eq_eq$28 = function(other) { var self = this; return self["native"] === $$$('::', 'Native').$try_convert(other) }, $Object_$eq_eq$28.$$arity = 1); Opal.def(self, '$has_key?', $Object_has_key$ques$29 = function(name) { var self = this; return Opal.hasOwnProperty.call(self["native"], name) }, $Object_has_key$ques$29.$$arity = 1); Opal.alias(self, "key?", "has_key?"); Opal.alias(self, "include?", "has_key?"); Opal.alias(self, "member?", "has_key?"); Opal.def(self, '$each', $Object_each$30 = function $$each($a) { var $post_args, args, $iter = $Object_each$30.$$p, $yield = $iter || nil, self = this; if ($iter) $Object_each$30.$$p = null; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if (($yield !== nil)) { for (var key in self["native"]) { Opal.yieldX($yield, [key, self["native"][key]]) } ; return self; } else { return $send(self, 'method_missing', ["each"].concat(Opal.to_a(args))) }; }, $Object_each$30.$$arity = -1); Opal.def(self, '$[]', $Object_$$$31 = function(key) { var self = this; var prop = self["native"][key]; if (prop instanceof Function) { return prop; } else { return $$$('::', 'Native').$call(self["native"], key) } }, $Object_$$$31.$$arity = 1); Opal.def(self, '$[]=', $Object_$$$eq$32 = function(key, value) { var self = this, native$ = nil; native$ = $$$('::', 'Native').$try_convert(value); if ($truthy(native$ === nil)) { return self["native"][key] = value } else { return self["native"][key] = native$ }; }, $Object_$$$eq$32.$$arity = 2); Opal.def(self, '$merge!', $Object_merge$excl$33 = function(other) { var self = this; other = $$$('::', 'Native').$convert(other); for (var prop in other) { self["native"][prop] = other[prop]; } ; return self; }, $Object_merge$excl$33.$$arity = 1); Opal.def(self, '$respond_to?', $Object_respond_to$ques$34 = function(name, include_all) { var self = this; if (include_all == null) { include_all = false; }; return $$$('::', 'Kernel').$instance_method("respond_to?").$bind(self).$call(name, include_all); }, $Object_respond_to$ques$34.$$arity = -2); Opal.def(self, '$respond_to_missing?', $Object_respond_to_missing$ques$35 = function(name, include_all) { var self = this; if (include_all == null) { include_all = false; }; return Opal.hasOwnProperty.call(self["native"], name); }, $Object_respond_to_missing$ques$35.$$arity = -2); Opal.def(self, '$method_missing', $Object_method_missing$36 = function $$method_missing(mid, $a) { var $iter = $Object_method_missing$36.$$p, block = $iter || nil, $post_args, args, self = this, $writer = nil; if ($iter) $Object_method_missing$36.$$p = null; if ($iter) $Object_method_missing$36.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if (mid.charAt(mid.length - 1) === '=') { return (($writer = [mid.$slice(0, $rb_minus(mid.$length(), 1)), args['$[]'](0)]), $send(self, '[]=', Opal.to_a($writer)), $writer[$rb_minus($writer["length"], 1)]); } else { return $send($$$('::', 'Native'), 'call', [self["native"], mid].concat(Opal.to_a(args)), block.$to_proc()); } ; }, $Object_method_missing$36.$$arity = -2); Opal.def(self, '$nil?', $Object_nil$ques$37 = function() { var self = this; return false }, $Object_nil$ques$37.$$arity = 0); Opal.def(self, '$is_a?', $Object_is_a$ques$38 = function(klass) { var self = this; return Opal.is_a(self, klass); }, $Object_is_a$ques$38.$$arity = 1); Opal.alias(self, "kind_of?", "is_a?"); Opal.def(self, '$instance_of?', $Object_instance_of$ques$39 = function(klass) { var self = this; return self.$$class === klass; }, $Object_instance_of$ques$39.$$arity = 1); Opal.def(self, '$class', $Object_class$40 = function() { var self = this; return self.$$class; }, $Object_class$40.$$arity = 0); Opal.def(self, '$to_a', $Object_to_a$41 = function $$to_a(options) { var $iter = $Object_to_a$41.$$p, block = $iter || nil, self = this; if ($iter) $Object_to_a$41.$$p = null; if ($iter) $Object_to_a$41.$$p = null;; if (options == null) { options = $hash2([], {}); }; return $send($$$($$$('::', 'Native'), 'Array'), 'new', [self["native"], options], block.$to_proc()).$to_a(); }, $Object_to_a$41.$$arity = -1); return (Opal.def(self, '$inspect', $Object_inspect$42 = function $$inspect() { var self = this; return "" + "#" }, $Object_inspect$42.$$arity = 0), nil) && 'inspect'; })($$($nesting, 'Native'), $$($nesting, 'BasicObject'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Array'); var $nesting = [self].concat($parent_nesting), $Array_initialize$43, $Array_each$44, $Array_$$$45, $Array_$$$eq$46, $Array_last$47, $Array_length$48, $Array_inspect$49; self.$$prototype.named = self.$$prototype["native"] = self.$$prototype.get = self.$$prototype.block = self.$$prototype.set = self.$$prototype.length = nil; self.$include($$$($$($nesting, 'Native'), 'Wrapper')); self.$include($$($nesting, 'Enumerable')); Opal.def(self, '$initialize', $Array_initialize$43 = function $$initialize(native$, options) { var $iter = $Array_initialize$43.$$p, block = $iter || nil, $a, self = this; if ($iter) $Array_initialize$43.$$p = null; if ($iter) $Array_initialize$43.$$p = null;; if (options == null) { options = $hash2([], {}); }; $send(self, Opal.find_super_dispatcher(self, 'initialize', $Array_initialize$43, false), [native$], null); self.get = ($truthy($a = options['$[]']("get")) ? $a : options['$[]']("access")); self.named = options['$[]']("named"); self.set = ($truthy($a = options['$[]']("set")) ? $a : options['$[]']("access")); self.length = ($truthy($a = options['$[]']("length")) ? $a : "length"); self.block = block; if ($truthy(self.$length() == null)) { return self.$raise($$($nesting, 'ArgumentError'), "no length found on the array-like object") } else { return nil }; }, $Array_initialize$43.$$arity = -2); Opal.def(self, '$each', $Array_each$44 = function $$each() { var $iter = $Array_each$44.$$p, block = $iter || nil, self = this; if ($iter) $Array_each$44.$$p = null; if ($iter) $Array_each$44.$$p = null;; if ($truthy(block)) { } else { return self.$enum_for("each") }; for (var i = 0, length = self.$length(); i < length; i++) { Opal.yield1(block, self['$[]'](i)); } ; return self; }, $Array_each$44.$$arity = 0); Opal.def(self, '$[]', $Array_$$$45 = function(index) { var self = this, result = nil, $case = nil; result = (function() {$case = index; if ($$($nesting, 'String')['$===']($case) || $$($nesting, 'Symbol')['$===']($case)) {if ($truthy(self.named)) { return self["native"][self.named](index) } else { return self["native"][index] }} else if ($$($nesting, 'Integer')['$===']($case)) {if ($truthy(self.get)) { return self["native"][self.get](index) } else { return self["native"][index] }} else { return nil }})(); if ($truthy(result)) { if ($truthy(self.block)) { return self.block.$call(result) } else { return self.$Native(result) } } else { return nil }; }, $Array_$$$45.$$arity = 1); Opal.def(self, '$[]=', $Array_$$$eq$46 = function(index, value) { var self = this; if ($truthy(self.set)) { return self["native"][self.set](index, $$($nesting, 'Native').$convert(value)) } else { return self["native"][index] = $$($nesting, 'Native').$convert(value) } }, $Array_$$$eq$46.$$arity = 2); Opal.def(self, '$last', $Array_last$47 = function $$last(count) { var $a, self = this, index = nil, result = nil; if (count == null) { count = nil; }; if ($truthy(count)) { index = $rb_minus(self.$length(), 1); result = []; while ($truthy($rb_ge(index, 0))) { result['$<<'](self['$[]'](index)); index = $rb_minus(index, 1); }; return result; } else { return self['$[]']($rb_minus(self.$length(), 1)) }; }, $Array_last$47.$$arity = -1); Opal.def(self, '$length', $Array_length$48 = function $$length() { var self = this; return self["native"][self.length] }, $Array_length$48.$$arity = 0); Opal.alias(self, "to_ary", "to_a"); return (Opal.def(self, '$inspect', $Array_inspect$49 = function $$inspect() { var self = this; return self.$to_a().$inspect() }, $Array_inspect$49.$$arity = 0), nil) && 'inspect'; })($$($nesting, 'Native'), null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Numeric'); var $nesting = [self].concat($parent_nesting), $Numeric_to_n$50; return (Opal.def(self, '$to_n', $Numeric_to_n$50 = function $$to_n() { var self = this; return self.valueOf(); }, $Numeric_to_n$50.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Proc'); var $nesting = [self].concat($parent_nesting), $Proc_to_n$51; return (Opal.def(self, '$to_n', $Proc_to_n$51 = function $$to_n() { var self = this; return self }, $Proc_to_n$51.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String_to_n$52; return (Opal.def(self, '$to_n', $String_to_n$52 = function $$to_n() { var self = this; return self.valueOf(); }, $String_to_n$52.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Regexp'); var $nesting = [self].concat($parent_nesting), $Regexp_to_n$53; return (Opal.def(self, '$to_n', $Regexp_to_n$53 = function $$to_n() { var self = this; return self.valueOf(); }, $Regexp_to_n$53.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'MatchData'); var $nesting = [self].concat($parent_nesting), $MatchData_to_n$54; self.$$prototype.matches = nil; return (Opal.def(self, '$to_n', $MatchData_to_n$54 = function $$to_n() { var self = this; return self.matches }, $MatchData_to_n$54.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Struct'); var $nesting = [self].concat($parent_nesting), $Struct_to_n$55; return (Opal.def(self, '$to_n', $Struct_to_n$55 = function $$to_n() { var $$56, self = this, result = nil; result = {}; $send(self, 'each_pair', [], ($$56 = function(name, value){var self = $$56.$$s || this; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return result[name] = $$($nesting, 'Native').$try_convert(value, value);}, $$56.$$s = self, $$56.$$arity = 2, $$56)); return result; }, $Struct_to_n$55.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Array'); var $nesting = [self].concat($parent_nesting), $Array_to_n$57; return (Opal.def(self, '$to_n', $Array_to_n$57 = function $$to_n() { var self = this; var result = []; for (var i = 0, length = self.length; i < length; i++) { var obj = self[i]; result.push($$($nesting, 'Native').$try_convert(obj, obj)); } return result; }, $Array_to_n$57.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Boolean'); var $nesting = [self].concat($parent_nesting), $Boolean_to_n$58; return (Opal.def(self, '$to_n', $Boolean_to_n$58 = function $$to_n() { var self = this; return self.valueOf(); }, $Boolean_to_n$58.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Time'); var $nesting = [self].concat($parent_nesting), $Time_to_n$59; return (Opal.def(self, '$to_n', $Time_to_n$59 = function $$to_n() { var self = this; return self }, $Time_to_n$59.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NilClass'); var $nesting = [self].concat($parent_nesting), $NilClass_to_n$60; return (Opal.def(self, '$to_n', $NilClass_to_n$60 = function $$to_n() { var self = this; return null; }, $NilClass_to_n$60.$$arity = 0), nil) && 'to_n' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Hash'); var $nesting = [self].concat($parent_nesting), $Hash_initialize$61, $Hash_to_n$62; Opal.alias(self, "_initialize", "initialize"); Opal.def(self, '$initialize', $Hash_initialize$61 = function $$initialize(defaults) { var $iter = $Hash_initialize$61.$$p, block = $iter || nil, self = this; if ($iter) $Hash_initialize$61.$$p = null; if ($iter) $Hash_initialize$61.$$p = null;; ; if (defaults != null && (defaults.constructor === undefined || defaults.constructor === Object)) { var smap = self.$$smap, keys = self.$$keys, key, value; for (key in defaults) { value = defaults[key]; if (value && (value.constructor === undefined || value.constructor === Object)) { smap[key] = $$($nesting, 'Hash').$new(value); } else if (value && value.$$is_array) { value = value.map(function(item) { if (item && (item.constructor === undefined || item.constructor === Object)) { return $$($nesting, 'Hash').$new(item); } return self.$Native(item); }); smap[key] = value } else { smap[key] = self.$Native(value); } keys.push(key); } return self; } return $send(self, '_initialize', [defaults], block.$to_proc()); ; }, $Hash_initialize$61.$$arity = -1); return (Opal.def(self, '$to_n', $Hash_to_n$62 = function $$to_n() { var self = this; var result = {}, keys = self.$$keys, smap = self.$$smap, key, value; for (var i = 0, length = keys.length; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = smap[key]; } else { key = key.key; value = key.value; } result[key] = $$($nesting, 'Native').$try_convert(value, value); } return result; }, $Hash_to_n$62.$$arity = 0), nil) && 'to_n'; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Module'); var $nesting = [self].concat($parent_nesting), $Module_native_module$63; return (Opal.def(self, '$native_module', $Module_native_module$63 = function $$native_module() { var self = this; return Opal.global[self.$name()] = self }, $Module_native_module$63.$$arity = 0), nil) && 'native_module' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Class'); var $nesting = [self].concat($parent_nesting), $Class_native_alias$64, $Class_native_class$65; Opal.def(self, '$native_alias', $Class_native_alias$64 = function $$native_alias(new_jsid, existing_mid) { var self = this; var aliased = self.prototype['$' + existing_mid]; if (!aliased) { self.$raise($$($nesting, 'NameError').$new("" + "undefined method `" + (existing_mid) + "' for class `" + (self.$inspect()) + "'", existing_mid)); } self.prototype[new_jsid] = aliased; }, $Class_native_alias$64.$$arity = 2); return (Opal.def(self, '$native_class', $Class_native_class$65 = function $$native_class() { var self = this; self.$native_module(); return self["new"] = self.$new;; }, $Class_native_class$65.$$arity = 0), nil) && 'native_class'; })($nesting[0], null, $nesting); return ($gvars.$ = ($gvars.global = self.$Native(Opal.global))); }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery/constants"] = function(Opal) { var $a, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $truthy = Opal.truthy; Opal.add_stubs(['$require', '$raise']); self.$require("native"); if ($truthy((($a = $$($nesting, 'JQUERY_CLASS', 'skip_raise')) ? 'constant' : nil))) { return nil } else { return (function() { if ($truthy(!!Opal.global.jQuery)) {return Opal.const_set($nesting[0], 'JQUERY_CLASS', Opal.const_set($nesting[0], 'JQUERY_SELECTOR', Opal.global.jQuery))} else if ($truthy(!!Opal.global.Zepto)) { Opal.const_set($nesting[0], 'JQUERY_SELECTOR', Opal.global.Zepto); return Opal.const_set($nesting[0], 'JQUERY_CLASS', Opal.global.Zepto.zepto.Z);} else {return self.$raise($$($nesting, 'NameError'), "Can't find jQuery or Zepto. jQuery must be included before opal-jquery")}})() }; }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery/element"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy; Opal.add_stubs(['$require', '$to_n', '$include', '$each', '$alias_native', '$attr_reader', '$call', '$nil?', '$raise', '$is_a?', '$has_key?', '$delete', '$from_object', '$gsub', '$upcase', '$[]', '$compact', '$map', '$respond_to?', '$<<', '$Native', '$arity', '$new']); self.$require("native"); self.$require("opal/jquery/constants"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting), $Element_find$1, $Element_$$$2, $Element_id$3, $Element_new$4, $Element_parse$5, $Element_expose$6, $Element_prop$8, $Element_to_n$9, $Element_$$$10, $Element_$$$eq$11, $Element_attr$12, $Element_has_attribute$ques$13, $Element_append_to_body$14, $Element_append_to_head$15, $Element_at$16, $Element_class_name$17, $Element_class_name$eq$18, $Element_css$19, $Element_animate$20, $Element_data$21, $Element_effect$22, $Element_visible$ques$25, $Element_offset$26, $Element_each$27, $Element_first$28, $Element_html$29, $Element_id$30, $Element_id$eq$31, $Element_tag_name$32, $Element_inspect$33, $Element_to_s$34, $Element_length$35, $Element_any$ques$36, $Element_empty$ques$37, $Element_on$38, $Element_one$39, $Element_off$40, $Element_serialize_array$41, $Element_value$43, $Element_height$44, $Element_width$45, $Element_position$46, $Element_$eq_eq$47, $Element_respond_to_missing$ques$48, $Element_method_missing$49; var $ = $$($nesting, 'JQUERY_SELECTOR').$to_n(); self.$include($$($nesting, 'Enumerable')); Opal.defs(self, '$find', $Element_find$1 = function $$find(selector) { var self = this; return $(selector) }, $Element_find$1.$$arity = 1); Opal.defs(self, '$[]', $Element_$$$2 = function(selector) { var self = this; return $(selector) }, $Element_$$$2.$$arity = 1); Opal.defs(self, '$id', $Element_id$3 = function $$id(id) { var self = this; var el = document.getElementById(id); if (!el) { return nil; } return $(el); }, $Element_id$3.$$arity = 1); Opal.defs(self, '$new', $Element_new$4 = function(tag) { var self = this; if (tag == null) { tag = "div"; }; return $(document.createElement(tag));; }, $Element_new$4.$$arity = -1); Opal.defs(self, '$parse', $Element_parse$5 = function $$parse(str) { var self = this; return $.parseHTML ? $($.parseHTML(str)) : $(str); }, $Element_parse$5.$$arity = 1); Opal.defs(self, '$expose', $Element_expose$6 = function $$expose($a) { var $post_args, methods, $$7, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); methods = $post_args;; return $send(methods, 'each', [], ($$7 = function(method){var self = $$7.$$s || this; if (method == null) { method = nil; }; return self.$alias_native(method);}, $$7.$$s = self, $$7.$$arity = 1, $$7)); }, $Element_expose$6.$$arity = -1); self.$attr_reader("selector"); self.$alias_native("after"); self.$alias_native("before"); self.$alias_native("parent"); self.$alias_native("parents"); self.$alias_native("prev"); self.$alias_native("remove"); self.$alias_native("hide"); self.$alias_native("show"); self.$alias_native("toggle"); self.$alias_native("children"); self.$alias_native("blur"); self.$alias_native("closest"); self.$alias_native("detach"); self.$alias_native("focus"); self.$alias_native("find"); self.$alias_native("next"); self.$alias_native("siblings"); self.$alias_native("text"); self.$alias_native("trigger"); self.$alias_native("append"); self.$alias_native("prepend"); self.$alias_native("serialize"); self.$alias_native("is"); self.$alias_native("filter"); self.$alias_native("not"); self.$alias_native("last"); self.$alias_native("wrap"); self.$alias_native("stop"); self.$alias_native("clone"); self.$alias_native("empty"); self.$alias_native("get"); Opal.def(self, '$prop', $Element_prop$8 = function $$prop($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send($$($nesting, 'Native'), 'call', [self, "prop"].concat(Opal.to_a(args))); }, $Element_prop$8.$$arity = -1); Opal.alias(self, "succ", "next"); Opal.alias(self, "<<", "append"); self.$alias_native("add_class", "addClass"); self.$alias_native("append_to", "appendTo"); self.$alias_native("has_class?", "hasClass"); self.$alias_native("html=", "html"); self.$alias_native("index"); self.$alias_native("is?", "is"); self.$alias_native("remove_attr", "removeAttr"); self.$alias_native("remove_class", "removeClass"); self.$alias_native("submit"); self.$alias_native("click"); self.$alias_native("text=", "text"); self.$alias_native("toggle_class", "toggleClass"); self.$alias_native("value=", "val"); self.$alias_native("scroll_top=", "scrollTop"); self.$alias_native("scroll_top", "scrollTop"); self.$alias_native("scroll_left=", "scrollLeft"); self.$alias_native("scroll_left", "scrollLeft"); self.$alias_native("remove_attribute", "removeAttr"); self.$alias_native("slide_down", "slideDown"); self.$alias_native("slide_up", "slideUp"); self.$alias_native("slide_toggle", "slideToggle"); self.$alias_native("fade_toggle", "fadeToggle"); self.$alias_native("height=", "height"); self.$alias_native("width=", "width"); self.$alias_native("outer_width", "outerWidth"); self.$alias_native("outer_height", "outerHeight"); Opal.def(self, '$to_n', $Element_to_n$9 = function $$to_n() { var self = this; return self }, $Element_to_n$9.$$arity = 0); Opal.def(self, '$[]', $Element_$$$10 = function(name) { var self = this; var value = self.attr(name); if(value === undefined) return nil; return value; }, $Element_$$$10.$$arity = 1); Opal.def(self, '$[]=', $Element_$$$eq$11 = function(name, value) { var self = this; if ($truthy(value['$nil?']())) { return self.removeAttr(name)}; return self.attr(name, value);; }, $Element_$$$eq$11.$$arity = 2); Opal.def(self, '$attr', $Element_attr$12 = function $$attr($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var size = args.length; switch (size) { case 1: var result = self.attr(args[0]); return( (result == null) ? nil : result ); break; case 2: return self.attr(args[0], args[1]); break; default: self.$raise($$($nesting, 'ArgumentError'), "#attr only accepts 1 or 2 arguments") } ; }, $Element_attr$12.$$arity = -1); Opal.def(self, '$has_attribute?', $Element_has_attribute$ques$13 = function(name) { var self = this; return self.attr(name) !== undefined; }, $Element_has_attribute$ques$13.$$arity = 1); Opal.def(self, '$append_to_body', $Element_append_to_body$14 = function $$append_to_body() { var self = this; return self.appendTo(document.body); }, $Element_append_to_body$14.$$arity = 0); Opal.def(self, '$append_to_head', $Element_append_to_head$15 = function $$append_to_head() { var self = this; return self.appendTo(document.head); }, $Element_append_to_head$15.$$arity = 0); Opal.def(self, '$at', $Element_at$16 = function $$at(index) { var self = this; var length = self.length; if (index < 0) { index += length; } if (index < 0 || index >= length) { return nil; } return $(self[index]); }, $Element_at$16.$$arity = 1); Opal.def(self, '$class_name', $Element_class_name$17 = function $$class_name() { var self = this; var first = self[0]; return (first && first.className) || ""; }, $Element_class_name$17.$$arity = 0); Opal.def(self, '$class_name=', $Element_class_name$eq$18 = function(name) { var self = this; for (var i = 0, length = self.length; i < length; i++) { self[i].className = name; } ; return self; }, $Element_class_name$eq$18.$$arity = 1); Opal.def(self, '$css', $Element_css$19 = function $$css(name, value) { var $a, self = this; if (value == null) { value = nil; }; if ($truthy(($truthy($a = value['$nil?']()) ? name['$is_a?']($$($nesting, 'String')) : $a))) { return self.css(name) } else if ($truthy(name['$is_a?']($$($nesting, 'Hash')))) { self.css(name.$to_n()) } else { self.css(name, value) }; return self; }, $Element_css$19.$$arity = -2); Opal.def(self, '$animate', $Element_animate$20 = function $$animate(params) { var $iter = $Element_animate$20.$$p, block = $iter || nil, self = this, speed = nil; if ($iter) $Element_animate$20.$$p = null; if ($iter) $Element_animate$20.$$p = null;; speed = (function() {if ($truthy(params['$has_key?']("speed"))) { return params.$delete("speed") } else { return 400 }; return nil; })(); if ((block !== nil)) { return self.animate(params.$to_n(), speed, block) } else { return self.animate(params.$to_n(), speed) }; }, $Element_animate$20.$$arity = 1); Opal.def(self, '$data', $Element_data$21 = function $$data($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; var result = self.data.apply(self, args); if ( (typeof(result) === 'object') && !(result instanceof $$($nesting, 'JQUERY_CLASS')) ) { result = $$($nesting, 'JSON').$from_object(result); } return result == null ? nil : result; ; }, $Element_data$21.$$arity = -1); Opal.def(self, '$effect', $Element_effect$22 = function $$effect(name, $a) { var $iter = $Element_effect$22.$$p, block = $iter || nil, $post_args, args, $$23, $$24, self = this; if ($iter) $Element_effect$22.$$p = null; if ($iter) $Element_effect$22.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; name = $send(name, 'gsub', [/_\w/], ($$23 = function(match){var self = $$23.$$s || this; if (match == null) { match = nil; }; return match['$[]'](1).$upcase();}, $$23.$$s = self, $$23.$$arity = 1, $$23)); args = $send(args, 'map', [], ($$24 = function(a){var self = $$24.$$s || this; if (a == null) { a = nil; }; if ($truthy(a['$respond_to?']("to_n"))) { return a.$to_n() } else { return nil };}, $$24.$$s = self, $$24.$$arity = 1, $$24)).$compact(); args['$<<'](function() { (function() {if ((block !== nil)) { return block.$call() } else { return nil }; return nil; })() }); return self[name].apply(self, args); }, $Element_effect$22.$$arity = -2); Opal.def(self, '$visible?', $Element_visible$ques$25 = function() { var self = this; return self.is(':visible'); }, $Element_visible$ques$25.$$arity = 0); Opal.def(self, '$offset', $Element_offset$26 = function $$offset() { var self = this; return self.$Native(self.offset()) }, $Element_offset$26.$$arity = 0); Opal.def(self, '$each', $Element_each$27 = function $$each() { var $iter = $Element_each$27.$$p, $yield = $iter || nil, self = this; if ($iter) $Element_each$27.$$p = null; for (var i = 0, length = self.length; i < length; i++) {; Opal.yield1($yield, $(self[i])); }; return self; }, $Element_each$27.$$arity = 0); Opal.def(self, '$first', $Element_first$28 = function $$first() { var self = this; return self.length ? self.first() : nil; }, $Element_first$28.$$arity = 0); Opal.def(self, '$html', $Element_html$29 = function $$html(content) { var self = this; ; if (content != null) { return self.html(content); } return self.html() || ''; ; }, $Element_html$29.$$arity = -1); Opal.def(self, '$id', $Element_id$30 = function $$id() { var self = this; var first = self[0]; return (first && first.id) || ""; }, $Element_id$30.$$arity = 0); Opal.def(self, '$id=', $Element_id$eq$31 = function(id) { var self = this; var first = self[0]; if (first) { first.id = id; } return self; }, $Element_id$eq$31.$$arity = 1); Opal.def(self, '$tag_name', $Element_tag_name$32 = function $$tag_name() { var self = this; return self.length > 0 ? self[0].tagName.toLowerCase() : nil }, $Element_tag_name$32.$$arity = 0); Opal.def(self, '$inspect', $Element_inspect$33 = function $$inspect() { var self = this; if (self[0] === document) return '#' else if (self[0] === window ) return '#' var val, el, str, result = []; for (var i = 0, length = self.length; i < length; i++) { el = self[i]; if (!el.tagName) { return '#'); } return '#'; }, $Element_inspect$33.$$arity = 0); Opal.def(self, '$to_s', $Element_to_s$34 = function $$to_s() { var self = this; var val, el, result = []; for (var i = 0, length = self.length; i < length; i++) { el = self[i]; result.push(el.outerHTML) } return result.join(', '); }, $Element_to_s$34.$$arity = 0); Opal.def(self, '$length', $Element_length$35 = function $$length() { var self = this; return self.length; }, $Element_length$35.$$arity = 0); Opal.def(self, '$any?', $Element_any$ques$36 = function() { var self = this; return self.length > 0; }, $Element_any$ques$36.$$arity = 0); Opal.def(self, '$empty?', $Element_empty$ques$37 = function() { var self = this; return self.length === 0; }, $Element_empty$ques$37.$$arity = 0); Opal.alias(self, "empty?", "none?"); Opal.def(self, '$on', $Element_on$38 = function $$on(name, sel) { var $iter = $Element_on$38.$$p, block = $iter || nil, self = this; if ($iter) $Element_on$38.$$p = null; if ($iter) $Element_on$38.$$p = null;; if (sel == null) { sel = nil; }; var has_args = block.$arity() !== 0; var wrapper = function() { for(var args = new Array(arguments.length), i = 0, ii = args.length; i < ii; i++) { args[i] = arguments[i]; } // Use preventDefault as a canary for native events if (has_args && args[0].preventDefault) { args[0] = $$($nesting, 'Event').$new(args[0]); } return block.apply(null, args); }; block.$$jqwrap = wrapper; if (sel == nil) { self.on(name, wrapper); } else { self.on(name, sel, wrapper); } ; return block; }, $Element_on$38.$$arity = -2); Opal.def(self, '$one', $Element_one$39 = function $$one(name, sel) { var $iter = $Element_one$39.$$p, block = $iter || nil, self = this; if ($iter) $Element_one$39.$$p = null; if ($iter) $Element_one$39.$$p = null;; if (sel == null) { sel = nil; }; var has_args = block.$arity() !== 0; var wrapper = function() { for(var args = new Array(arguments.length), i = 0, ii = args.length; i < ii; i++) { args[i] = arguments[i]; } // Use preventDefault as a canary for native events if (has_args && args[0].preventDefault) { args[0] = $$($nesting, 'Event').$new(args[0]); } return block.apply(null, args); }; block.$$jqwrap = wrapper; if (sel == nil) { self.one(name, wrapper); } else { self.one(name, sel, wrapper); } ; return block; }, $Element_one$39.$$arity = -2); Opal.def(self, '$off', $Element_off$40 = function $$off(name, sel, block) { var self = this; if (block == null) { block = nil; }; if (sel == null) { return self.off(name); } else if (block === nil) { return self.off(name, sel.$$jqwrap); } else { return self.off(name, sel, block.$$jqwrap); } ; }, $Element_off$40.$$arity = -3); Opal.def(self, '$serialize_array', $Element_serialize_array$41 = function $$serialize_array() { var $$42, self = this; return $send((self.serializeArray()), 'map', [], ($$42 = function(e){var self = $$42.$$s || this; if (e == null) { e = nil; }; return $$($nesting, 'Hash').$new(e);}, $$42.$$s = self, $$42.$$arity = 1, $$42)) }, $Element_serialize_array$41.$$arity = 0); Opal.alias(self, "size", "length"); Opal.def(self, '$value', $Element_value$43 = function $$value() { var $a, self = this; return ($truthy($a = self.val()) ? $a : "") }, $Element_value$43.$$arity = 0); Opal.def(self, '$height', $Element_height$44 = function $$height() { var $a, self = this; return ($truthy($a = self.height()) ? $a : nil) }, $Element_height$44.$$arity = 0); Opal.def(self, '$width', $Element_width$45 = function $$width() { var $a, self = this; return ($truthy($a = self.width()) ? $a : nil) }, $Element_width$45.$$arity = 0); Opal.def(self, '$position', $Element_position$46 = function $$position() { var self = this; return self.$Native(self.position()) }, $Element_position$46.$$arity = 0); Opal.def(self, '$==', $Element_$eq_eq$47 = function(other) { var self = this; return self.is(other); }, $Element_$eq_eq$47.$$arity = 1); Opal.def(self, '$respond_to_missing?', $Element_respond_to_missing$ques$48 = function(name, _) { var $iter = $Element_respond_to_missing$ques$48.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Element_respond_to_missing$ques$48.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } var method = self[name]; if (typeof(method) === 'function') { return true; } else { return $send(self, Opal.find_super_dispatcher(self, 'respond_to_missing?', $Element_respond_to_missing$ques$48, false), $zuper, $iter); } }, $Element_respond_to_missing$ques$48.$$arity = 2); return (Opal.def(self, '$method_missing', $Element_method_missing$49 = function $$method_missing(name, $a) { var $iter = $Element_method_missing$49.$$p, block = $iter || nil, $post_args, args, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Element_method_missing$49.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($iter) $Element_method_missing$49.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ((block !== nil)) { args['$<<'](block)}; var method = self[name]; if (typeof(method) === 'function') { return method.apply(self, args.$to_n()); } else { return $send(self, Opal.find_super_dispatcher(self, 'method_missing', $Element_method_missing$49, false), $zuper, $iter); } ; }, $Element_method_missing$49.$$arity = -2), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'JQUERY_CLASS').$to_n(), $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery/window"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $gvars = Opal.gvars; Opal.add_stubs(['$require', '$include', '$find', '$on', '$element', '$to_proc', '$off', '$trigger', '$new']); self.$require("opal/jquery/element"); (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Window'); var $nesting = [self].concat($parent_nesting), $a, $b, $Window_element$1, $Window_on$2, $Window_off$3, $Window_trigger$4; self.$$prototype.element = nil; self.$include((function() {if ($truthy((($b = $$($nesting, 'Native', 'skip_raise')) && ($a = $$$($b, 'Wrapper', 'skip_raise')) ? 'constant' : nil))) { return $$$($$($nesting, 'Native'), 'Wrapper') } else { return $$($nesting, 'Native') }; return nil; })()); Opal.def(self, '$element', $Window_element$1 = function $$element() { var $a, self = this; return (self.element = ($truthy($a = self.element) ? $a : $$($nesting, 'Element').$find(window))) }, $Window_element$1.$$arity = 0); Opal.def(self, '$on', $Window_on$2 = function $$on($a) { var $iter = $Window_on$2.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Window_on$2.$$p = null; if ($iter) $Window_on$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.$element(), 'on', Opal.to_a(args), block.$to_proc()); }, $Window_on$2.$$arity = -1); Opal.def(self, '$off', $Window_off$3 = function $$off($a) { var $iter = $Window_off$3.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Window_off$3.$$p = null; if ($iter) $Window_off$3.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.$element(), 'off', Opal.to_a(args), block.$to_proc()); }, $Window_off$3.$$arity = -1); return (Opal.def(self, '$trigger', $Window_trigger$4 = function $$trigger($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.$element(), 'trigger', Opal.to_a(args)); }, $Window_trigger$4.$$arity = -1), nil) && 'trigger'; })($nesting[0], null, $nesting) })($nesting[0], $nesting); Opal.const_set($nesting[0], 'Window', $$$($$($nesting, 'Browser'), 'Window').$new(window)); return ($gvars.window = $$($nesting, 'Window')); }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery/document"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy, $send = Opal.send, $gvars = Opal.gvars; Opal.add_stubs(['$require', '$to_n', '$call', '$new', '$ready?', '$resolve', '$module_function', '$find', '$extend']); self.$require("opal/jquery/constants"); self.$require("opal/jquery/element"); (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DocumentMethods'); var $nesting = [self].concat($parent_nesting), $DocumentMethods_ready$ques$1, $DocumentMethods_ready$2, $DocumentMethods$4, $DocumentMethods_title$5, $DocumentMethods_title$eq$6, $DocumentMethods_head$7, $DocumentMethods_body$8; var $ = $$($nesting, 'JQUERY_SELECTOR').$to_n(); Opal.def(self, '$ready?', $DocumentMethods_ready$ques$1 = function() { var $iter = $DocumentMethods_ready$ques$1.$$p, block = $iter || nil, $a, self = this; if ($iter) $DocumentMethods_ready$ques$1.$$p = null; if ($iter) $DocumentMethods_ready$ques$1.$$p = null;; if ((block !== nil)) { if ($truthy((($a = $nesting[0].$$cvars['@@__isReady']) == null ? nil : $a))) { return block.$call() } else { return $(block) } } else { return nil }; }, $DocumentMethods_ready$ques$1.$$arity = 0); Opal.def(self, '$ready', $DocumentMethods_ready$2 = function $$ready() { var $$3, self = this, promise = nil; promise = $$($nesting, 'Promise').$new(); $send($$($nesting, 'Document'), 'ready?', [], ($$3 = function(){var self = $$3.$$s || this; return promise.$resolve()}, $$3.$$s = self, $$3.$$arity = 0, $$3)); return promise; }, $DocumentMethods_ready$2.$$arity = 0); self.$module_function("ready?"); $send(self, 'ready?', [], ($DocumentMethods$4 = function(){var self = $DocumentMethods$4.$$s || this; return (Opal.class_variable_set($nesting[0], '@@__isReady', true))}, $DocumentMethods$4.$$s = self, $DocumentMethods$4.$$arity = 0, $DocumentMethods$4)); Opal.def(self, '$title', $DocumentMethods_title$5 = function $$title() { var self = this; return document.title; }, $DocumentMethods_title$5.$$arity = 0); Opal.def(self, '$title=', $DocumentMethods_title$eq$6 = function(title) { var self = this; return document.title = title; }, $DocumentMethods_title$eq$6.$$arity = 1); Opal.def(self, '$head', $DocumentMethods_head$7 = function $$head() { var self = this; return $$($nesting, 'Element').$find(document.head) }, $DocumentMethods_head$7.$$arity = 0); Opal.def(self, '$body', $DocumentMethods_body$8 = function $$body() { var self = this; return $$($nesting, 'Element').$find(document.body) }, $DocumentMethods_body$8.$$arity = 0); })($nesting[0], $nesting) })($nesting[0], $nesting); Opal.const_set($nesting[0], 'Document', $$($nesting, 'Element').$find(document)); $$($nesting, 'Document').$extend($$$($$($nesting, 'Browser'), 'DocumentMethods')); return ($gvars.document = $$($nesting, 'Document')); }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery/event"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass; Opal.add_stubs(['$require', '$to_n', '$stop', '$prevent']); self.$require("opal/jquery/constants"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting), $Event_initialize$1, $Event_to_n$2, $Event_$$$3, $Event_type$4, $Event_element$5, $Event_target$6, $Event_prevented$ques$7, $Event_prevent$8, $Event_stopped$ques$9, $Event_stop$10, $Event_stop_immediate$11, $Event_kill$12, $Event_page_x$13, $Event_page_y$14, $Event_touch_x$15, $Event_touch_y$16, $Event_ctrl_key$17, $Event_meta_key$18, $Event_alt_key$19, $Event_shift_key$20, $Event_key_code$21, $Event_which$22; self.$$prototype["native"] = nil; var $ = $$($nesting, 'JQUERY_SELECTOR').$to_n(); Opal.def(self, '$initialize', $Event_initialize$1 = function $$initialize(native$) { var self = this; return (self["native"] = native$) }, $Event_initialize$1.$$arity = 1); Opal.def(self, '$to_n', $Event_to_n$2 = function $$to_n() { var self = this; return self["native"] }, $Event_to_n$2.$$arity = 0); Opal.def(self, '$[]', $Event_$$$3 = function(name) { var self = this; return self["native"][name] }, $Event_$$$3.$$arity = 1); Opal.def(self, '$type', $Event_type$4 = function $$type() { var self = this; return self["native"].type }, $Event_type$4.$$arity = 0); Opal.def(self, '$element', $Event_element$5 = function $$element() { var self = this; return $(self["native"].currentTarget) }, $Event_element$5.$$arity = 0); Opal.alias(self, "current_target", "element"); Opal.def(self, '$target', $Event_target$6 = function $$target() { var self = this; return $(self["native"].target) }, $Event_target$6.$$arity = 0); Opal.def(self, '$prevented?', $Event_prevented$ques$7 = function() { var self = this; return self["native"].isDefaultPrevented() }, $Event_prevented$ques$7.$$arity = 0); Opal.def(self, '$prevent', $Event_prevent$8 = function $$prevent() { var self = this; return self["native"].preventDefault() }, $Event_prevent$8.$$arity = 0); Opal.def(self, '$stopped?', $Event_stopped$ques$9 = function() { var self = this; return self["native"].isPropagationStopped() }, $Event_stopped$ques$9.$$arity = 0); Opal.def(self, '$stop', $Event_stop$10 = function $$stop() { var self = this; return self["native"].stopPropagation() }, $Event_stop$10.$$arity = 0); Opal.def(self, '$stop_immediate', $Event_stop_immediate$11 = function $$stop_immediate() { var self = this; return self["native"].stopImmediatePropagation() }, $Event_stop_immediate$11.$$arity = 0); Opal.def(self, '$kill', $Event_kill$12 = function $$kill() { var self = this; self.$stop(); return self.$prevent(); }, $Event_kill$12.$$arity = 0); Opal.def(self, '$page_x', $Event_page_x$13 = function $$page_x() { var self = this; return self["native"].pageX }, $Event_page_x$13.$$arity = 0); Opal.def(self, '$page_y', $Event_page_y$14 = function $$page_y() { var self = this; return self["native"].pageY }, $Event_page_y$14.$$arity = 0); Opal.def(self, '$touch_x', $Event_touch_x$15 = function $$touch_x() { var self = this; return self["native"].originalEvent.touches[0].pageX }, $Event_touch_x$15.$$arity = 0); Opal.def(self, '$touch_y', $Event_touch_y$16 = function $$touch_y() { var self = this; return self["native"].originalEvent.touches[0].pageY }, $Event_touch_y$16.$$arity = 0); Opal.def(self, '$ctrl_key', $Event_ctrl_key$17 = function $$ctrl_key() { var self = this; return self["native"].ctrlKey }, $Event_ctrl_key$17.$$arity = 0); Opal.def(self, '$meta_key', $Event_meta_key$18 = function $$meta_key() { var self = this; return self["native"].metaKey }, $Event_meta_key$18.$$arity = 0); Opal.def(self, '$alt_key', $Event_alt_key$19 = function $$alt_key() { var self = this; return self["native"].altKey }, $Event_alt_key$19.$$arity = 0); Opal.def(self, '$shift_key', $Event_shift_key$20 = function $$shift_key() { var self = this; return self["native"].shiftKey }, $Event_shift_key$20.$$arity = 0); Opal.def(self, '$key_code', $Event_key_code$21 = function $$key_code() { var self = this; return self["native"].keyCode }, $Event_key_code$21.$$arity = 0); Opal.def(self, '$which', $Event_which$22 = function $$which() { var self = this; return self["native"].which }, $Event_which$22.$$arity = 0); Opal.alias(self, "default_prevented?", "prevented?"); Opal.alias(self, "prevent_default", "prevent"); Opal.alias(self, "propagation_stopped?", "stopped?"); Opal.alias(self, "stop_propagation", "stop"); return Opal.alias(self, "stop_immediate_propagation", "stop_immediate"); })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["json"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2, $truthy = Opal.truthy; Opal.add_stubs(['$raise', '$new', '$push', '$[]=', '$-', '$[]', '$create_id', '$json_create', '$const_get', '$attr_accessor', '$create_id=', '$===', '$parse', '$generate', '$from_object', '$merge', '$to_json', '$responds_to?', '$to_io', '$write', '$to_s', '$to_a', '$strftime']); (function($base, $parent_nesting) { var self = $module($base, 'JSON'); var $nesting = [self].concat($parent_nesting), $JSON_$$$1, $JSON_parse$2, $JSON_parse$excl$3, $JSON_load$4, $JSON_from_object$5, $JSON_generate$6, $JSON_dump$7, $writer = nil; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'JSONError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'StandardError'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'ParserError'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'JSONError'), $nesting); var $hasOwn = Opal.hasOwnProperty; function $parse(source) { try { return JSON.parse(source); } catch (e) { self.$raise($$$($$($nesting, 'JSON'), 'ParserError'), e.message); } }; function to_opal(value, options) { var klass, arr, hash, i, ii, k; switch (typeof value) { case 'string': return value; case 'number': return value; case 'boolean': return !!value; case 'null': return nil; case 'object': if (!value) return nil; if (value.$$is_array) { arr = (options.array_class).$new(); for (i = 0, ii = value.length; i < ii; i++) { (arr).$push(to_opal(value[i], options)); } return arr; } else { hash = (options.object_class).$new(); for (k in value) { if ($hasOwn.call(value, k)) { (($writer = [k, to_opal(value[k], options)]), $send((hash), '[]=', Opal.to_a($writer)), $writer[$rb_minus($writer["length"], 1)]); } } if (!options.parse && (klass = (hash)['$[]']($$($nesting, 'JSON').$create_id())) != nil) { return $$$('::', 'Object').$const_get(klass).$json_create(hash); } else { return hash; } } } }; ; (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting); return self.$attr_accessor("create_id") })(Opal.get_singleton_class(self), $nesting); $writer = ["json_class"]; $send(self, 'create_id=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; Opal.defs(self, '$[]', $JSON_$$$1 = function(value, options) { var self = this; if (options == null) { options = $hash2([], {}); }; if ($truthy($$($nesting, 'String')['$==='](value))) { return self.$parse(value, options) } else { return self.$generate(value, options) }; }, $JSON_$$$1.$$arity = -2); Opal.defs(self, '$parse', $JSON_parse$2 = function $$parse(source, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return self.$from_object($parse(source), options.$merge($hash2(["parse"], {"parse": true}))); }, $JSON_parse$2.$$arity = -2); Opal.defs(self, '$parse!', $JSON_parse$excl$3 = function(source, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return self.$parse(source, options); }, $JSON_parse$excl$3.$$arity = -2); Opal.defs(self, '$load', $JSON_load$4 = function $$load(source, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return self.$from_object($parse(source), options); }, $JSON_load$4.$$arity = -2); Opal.defs(self, '$from_object', $JSON_from_object$5 = function $$from_object(js_object, options) { var $a, self = this, $writer = nil; if (options == null) { options = $hash2([], {}); }; ($truthy($a = options['$[]']("object_class")) ? $a : (($writer = ["object_class", $$($nesting, 'Hash')]), $send(options, '[]=', Opal.to_a($writer)), $writer[$rb_minus($writer["length"], 1)])); ($truthy($a = options['$[]']("array_class")) ? $a : (($writer = ["array_class", $$($nesting, 'Array')]), $send(options, '[]=', Opal.to_a($writer)), $writer[$rb_minus($writer["length"], 1)])); return to_opal(js_object, options.$$smap);; }, $JSON_from_object$5.$$arity = -2); Opal.defs(self, '$generate', $JSON_generate$6 = function $$generate(obj, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return obj.$to_json(options); }, $JSON_generate$6.$$arity = -2); Opal.defs(self, '$dump', $JSON_dump$7 = function $$dump(obj, io, limit) { var self = this, string = nil; if (io == null) { io = nil; }; if (limit == null) { limit = nil; }; string = self.$generate(obj); if ($truthy(io)) { if ($truthy(io['$responds_to?']("to_io"))) { io = io.$to_io()}; io.$write(string); return io; } else { return string }; }, $JSON_dump$7.$$arity = -2); })($nesting[0], $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Object'); var $nesting = [self].concat($parent_nesting), $Object_to_json$8; return (Opal.def(self, '$to_json', $Object_to_json$8 = function $$to_json() { var self = this; return self.$to_s().$to_json() }, $Object_to_json$8.$$arity = 0), nil) && 'to_json' })($nesting[0], null, $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Enumerable'); var $nesting = [self].concat($parent_nesting), $Enumerable_to_json$9; Opal.def(self, '$to_json', $Enumerable_to_json$9 = function $$to_json() { var self = this; return self.$to_a().$to_json() }, $Enumerable_to_json$9.$$arity = 0) })($nesting[0], $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Array'); var $nesting = [self].concat($parent_nesting), $Array_to_json$10; return (Opal.def(self, '$to_json', $Array_to_json$10 = function $$to_json() { var self = this; var result = []; for (var i = 0, length = self.length; i < length; i++) { result.push((self[i]).$to_json()); } return '[' + result.join(', ') + ']'; }, $Array_to_json$10.$$arity = 0), nil) && 'to_json' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Boolean'); var $nesting = [self].concat($parent_nesting), $Boolean_to_json$11; return (Opal.def(self, '$to_json', $Boolean_to_json$11 = function $$to_json() { var self = this; return (self == true) ? 'true' : 'false'; }, $Boolean_to_json$11.$$arity = 0), nil) && 'to_json' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Hash'); var $nesting = [self].concat($parent_nesting), $Hash_to_json$12; return (Opal.def(self, '$to_json', $Hash_to_json$12 = function $$to_json() { var self = this; var result = []; for (var i = 0, keys = self.$$keys, length = keys.length, key, value; i < length; i++) { key = keys[i]; if (key.$$is_string) { value = self.$$smap[key]; } else { value = key.value; key = key.key; } result.push((key).$to_s().$to_json() + ':' + (value).$to_json()); } return '{' + result.join(', ') + '}'; }, $Hash_to_json$12.$$arity = 0), nil) && 'to_json' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NilClass'); var $nesting = [self].concat($parent_nesting), $NilClass_to_json$13; return (Opal.def(self, '$to_json', $NilClass_to_json$13 = function $$to_json() { var self = this; return "null" }, $NilClass_to_json$13.$$arity = 0), nil) && 'to_json' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Numeric'); var $nesting = [self].concat($parent_nesting), $Numeric_to_json$14; return (Opal.def(self, '$to_json', $Numeric_to_json$14 = function $$to_json() { var self = this; return self.toString(); }, $Numeric_to_json$14.$$arity = 0), nil) && 'to_json' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting); return Opal.alias(self, "to_json", "inspect") })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Time'); var $nesting = [self].concat($parent_nesting), $Time_to_json$15; return (Opal.def(self, '$to_json', $Time_to_json$15 = function $$to_json() { var self = this; return self.$strftime("%FT%T%z").$to_json() }, $Time_to_json$15.$$arity = 0), nil) && 'to_json' })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Date'); var $nesting = [self].concat($parent_nesting), $Date_to_json$16, $Date_as_json$17; Opal.def(self, '$to_json', $Date_to_json$16 = function $$to_json() { var self = this; return self.$to_s().$to_json() }, $Date_to_json$16.$$arity = 0); return (Opal.def(self, '$as_json', $Date_as_json$17 = function $$as_json() { var self = this; return self.$to_s() }, $Date_as_json$17.$$arity = 0), nil) && 'as_json'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["promise"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_le(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs <= rhs : lhs['$<='](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$resolve', '$new', '$reject', '$attr_reader', '$===', '$value', '$key?', '$keys', '$!=', '$==', '$<<', '$>>', '$exception?', '$[]', '$resolved?', '$rejected?', '$!', '$error', '$include?', '$action', '$realized?', '$raise', '$^', '$call', '$resolve!', '$exception!', '$any?', '$each', '$reject!', '$there_can_be_only_one!', '$then', '$to_proc', '$fail', '$always', '$trace', '$class', '$object_id', '$+', '$inspect', '$act?', '$nil?', '$prev', '$push', '$concat', '$it', '$proc', '$reverse', '$pop', '$<=', '$length', '$shift', '$-', '$wait', '$map', '$reduce', '$try', '$tap', '$all?', '$find']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Promise'); var $nesting = [self].concat($parent_nesting), $Promise_value$1, $Promise_error$2, $Promise_when$3, $Promise_initialize$4, $Promise_value$5, $Promise_act$ques$6, $Promise_action$7, $Promise_exception$ques$8, $Promise_realized$ques$9, $Promise_resolved$ques$10, $Promise_rejected$ques$11, $Promise_$$12, $Promise_$lt$lt$13, $Promise_$gt$gt$14, $Promise_resolve$15, $Promise_resolve$excl$16, $Promise_reject$18, $Promise_reject$excl$19, $Promise_exception$excl$21, $Promise_then$22, $Promise_then$excl$23, $Promise_fail$24, $Promise_fail$excl$25, $Promise_always$26, $Promise_always$excl$27, $Promise_trace$28, $Promise_trace$excl$29, $Promise_there_can_be_only_one$excl$30, $Promise_inspect$31; self.$$prototype.value = self.$$prototype.action = self.$$prototype.exception = self.$$prototype.realized = self.$$prototype.next = self.$$prototype.delayed = self.$$prototype.error = self.$$prototype.prev = nil; Opal.defs(self, '$value', $Promise_value$1 = function $$value(value) { var self = this; return self.$new().$resolve(value) }, $Promise_value$1.$$arity = 1); Opal.defs(self, '$error', $Promise_error$2 = function $$error(value) { var self = this; return self.$new().$reject(value) }, $Promise_error$2.$$arity = 1); Opal.defs(self, '$when', $Promise_when$3 = function $$when($a) { var $post_args, promises, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); promises = $post_args;; return $$($nesting, 'When').$new(promises); }, $Promise_when$3.$$arity = -1); self.$attr_reader("error", "prev", "next"); Opal.def(self, '$initialize', $Promise_initialize$4 = function $$initialize(action) { var self = this; if (action == null) { action = $hash2([], {}); }; self.action = action; self.realized = false; self.exception = false; self.value = nil; self.error = nil; self.delayed = false; self.prev = nil; return (self.next = []); }, $Promise_initialize$4.$$arity = -1); Opal.def(self, '$value', $Promise_value$5 = function $$value() { var self = this; if ($truthy($$($nesting, 'Promise')['$==='](self.value))) { return self.value.$value() } else { return self.value } }, $Promise_value$5.$$arity = 0); Opal.def(self, '$act?', $Promise_act$ques$6 = function() { var $a, self = this; return ($truthy($a = self.action['$key?']("success")) ? $a : self.action['$key?']("always")) }, $Promise_act$ques$6.$$arity = 0); Opal.def(self, '$action', $Promise_action$7 = function $$action() { var self = this; return self.action.$keys() }, $Promise_action$7.$$arity = 0); Opal.def(self, '$exception?', $Promise_exception$ques$8 = function() { var self = this; return self.exception }, $Promise_exception$ques$8.$$arity = 0); Opal.def(self, '$realized?', $Promise_realized$ques$9 = function() { var self = this; return self.realized['$!='](false) }, $Promise_realized$ques$9.$$arity = 0); Opal.def(self, '$resolved?', $Promise_resolved$ques$10 = function() { var self = this; return self.realized['$==']("resolve") }, $Promise_resolved$ques$10.$$arity = 0); Opal.def(self, '$rejected?', $Promise_rejected$ques$11 = function() { var self = this; return self.realized['$==']("reject") }, $Promise_rejected$ques$11.$$arity = 0); Opal.def(self, '$^', $Promise_$$12 = function(promise) { var self = this; promise['$<<'](self); self['$>>'](promise); return promise; }, $Promise_$$12.$$arity = 1); Opal.def(self, '$<<', $Promise_$lt$lt$13 = function(promise) { var self = this; self.prev = promise; return self; }, $Promise_$lt$lt$13.$$arity = 1); Opal.def(self, '$>>', $Promise_$gt$gt$14 = function(promise) { var $a, self = this; self.next['$<<'](promise); if ($truthy(self['$exception?']())) { promise.$reject(self.delayed['$[]'](0)) } else if ($truthy(self['$resolved?']())) { promise.$resolve((function() {if ($truthy(self.delayed)) { return self.delayed['$[]'](0) } else { return self.$value() }; return nil; })()) } else if ($truthy(self['$rejected?']())) { if ($truthy(($truthy($a = self.action['$key?']("failure")['$!']()) ? $a : $$($nesting, 'Promise')['$===']((function() {if ($truthy(self.delayed)) { return self.delayed['$[]'](0) } else { return self.error }; return nil; })())))) { promise.$reject((function() {if ($truthy(self.delayed)) { return self.delayed['$[]'](0) } else { return self.$error() }; return nil; })()) } else if ($truthy(promise.$action()['$include?']("always"))) { promise.$reject((function() {if ($truthy(self.delayed)) { return self.delayed['$[]'](0) } else { return self.$error() }; return nil; })())}}; return self; }, $Promise_$gt$gt$14.$$arity = 1); Opal.def(self, '$resolve', $Promise_resolve$15 = function $$resolve(value) { var $a, self = this, block = nil, e = nil; if (value == null) { value = nil; }; if ($truthy(self['$realized?']())) { self.$raise($$($nesting, 'ArgumentError'), "the promise has already been realized")}; if ($truthy($$($nesting, 'Promise')['$==='](value))) { return value['$<<'](self.prev)['$^'](self)}; try { block = ($truthy($a = self.action['$[]']("success")) ? $a : self.action['$[]']("always")); if ($truthy(block)) { value = block.$call(value)}; self['$resolve!'](value); } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'Exception')])) {e = $err; try { self['$exception!'](e) } finally { Opal.pop_exception() } } else { throw $err; } };; return self; }, $Promise_resolve$15.$$arity = -1); Opal.def(self, '$resolve!', $Promise_resolve$excl$16 = function(value) { var $$17, self = this; self.realized = "resolve"; self.value = value; if ($truthy(self.next['$any?']())) { return $send(self.next, 'each', [], ($$17 = function(p){var self = $$17.$$s || this; if (p == null) { p = nil; }; return p.$resolve(value);}, $$17.$$s = self, $$17.$$arity = 1, $$17)) } else { return (self.delayed = [value]) }; }, $Promise_resolve$excl$16.$$arity = 1); Opal.def(self, '$reject', $Promise_reject$18 = function $$reject(value) { var $a, self = this, block = nil, e = nil; if (value == null) { value = nil; }; if ($truthy(self['$realized?']())) { self.$raise($$($nesting, 'ArgumentError'), "the promise has already been realized")}; if ($truthy($$($nesting, 'Promise')['$==='](value))) { return value['$<<'](self.prev)['$^'](self)}; try { block = ($truthy($a = self.action['$[]']("failure")) ? $a : self.action['$[]']("always")); if ($truthy(block)) { value = block.$call(value)}; if ($truthy(self.action['$key?']("always"))) { self['$resolve!'](value) } else { self['$reject!'](value) }; } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'Exception')])) {e = $err; try { self['$exception!'](e) } finally { Opal.pop_exception() } } else { throw $err; } };; return self; }, $Promise_reject$18.$$arity = -1); Opal.def(self, '$reject!', $Promise_reject$excl$19 = function(value) { var $$20, self = this; self.realized = "reject"; self.error = value; if ($truthy(self.next['$any?']())) { return $send(self.next, 'each', [], ($$20 = function(p){var self = $$20.$$s || this; if (p == null) { p = nil; }; return p.$reject(value);}, $$20.$$s = self, $$20.$$arity = 1, $$20)) } else { return (self.delayed = [value]) }; }, $Promise_reject$excl$19.$$arity = 1); Opal.def(self, '$exception!', $Promise_exception$excl$21 = function(error) { var self = this; self.exception = true; return self['$reject!'](error); }, $Promise_exception$excl$21.$$arity = 1); Opal.def(self, '$then', $Promise_then$22 = function $$then() { var $iter = $Promise_then$22.$$p, block = $iter || nil, self = this; if ($iter) $Promise_then$22.$$p = null; if ($iter) $Promise_then$22.$$p = null;; return self['$^']($$($nesting, 'Promise').$new($hash2(["success"], {"success": block}))); }, $Promise_then$22.$$arity = 0); Opal.def(self, '$then!', $Promise_then$excl$23 = function() { var $iter = $Promise_then$excl$23.$$p, block = $iter || nil, self = this; if ($iter) $Promise_then$excl$23.$$p = null; if ($iter) $Promise_then$excl$23.$$p = null;; self['$there_can_be_only_one!'](); return $send(self, 'then', [], block.$to_proc()); }, $Promise_then$excl$23.$$arity = 0); Opal.alias(self, "do", "then"); Opal.alias(self, "do!", "then!"); Opal.def(self, '$fail', $Promise_fail$24 = function $$fail() { var $iter = $Promise_fail$24.$$p, block = $iter || nil, self = this; if ($iter) $Promise_fail$24.$$p = null; if ($iter) $Promise_fail$24.$$p = null;; return self['$^']($$($nesting, 'Promise').$new($hash2(["failure"], {"failure": block}))); }, $Promise_fail$24.$$arity = 0); Opal.def(self, '$fail!', $Promise_fail$excl$25 = function() { var $iter = $Promise_fail$excl$25.$$p, block = $iter || nil, self = this; if ($iter) $Promise_fail$excl$25.$$p = null; if ($iter) $Promise_fail$excl$25.$$p = null;; self['$there_can_be_only_one!'](); return $send(self, 'fail', [], block.$to_proc()); }, $Promise_fail$excl$25.$$arity = 0); Opal.alias(self, "rescue", "fail"); Opal.alias(self, "catch", "fail"); Opal.alias(self, "rescue!", "fail!"); Opal.alias(self, "catch!", "fail!"); Opal.def(self, '$always', $Promise_always$26 = function $$always() { var $iter = $Promise_always$26.$$p, block = $iter || nil, self = this; if ($iter) $Promise_always$26.$$p = null; if ($iter) $Promise_always$26.$$p = null;; return self['$^']($$($nesting, 'Promise').$new($hash2(["always"], {"always": block}))); }, $Promise_always$26.$$arity = 0); Opal.def(self, '$always!', $Promise_always$excl$27 = function() { var $iter = $Promise_always$excl$27.$$p, block = $iter || nil, self = this; if ($iter) $Promise_always$excl$27.$$p = null; if ($iter) $Promise_always$excl$27.$$p = null;; self['$there_can_be_only_one!'](); return $send(self, 'always', [], block.$to_proc()); }, $Promise_always$excl$27.$$arity = 0); Opal.alias(self, "finally", "always"); Opal.alias(self, "ensure", "always"); Opal.alias(self, "finally!", "always!"); Opal.alias(self, "ensure!", "always!"); Opal.def(self, '$trace', $Promise_trace$28 = function $$trace(depth) { var $iter = $Promise_trace$28.$$p, block = $iter || nil, self = this; if ($iter) $Promise_trace$28.$$p = null; if ($iter) $Promise_trace$28.$$p = null;; if (depth == null) { depth = nil; }; return self['$^']($$($nesting, 'Trace').$new(depth, block)); }, $Promise_trace$28.$$arity = -1); Opal.def(self, '$trace!', $Promise_trace$excl$29 = function($a) { var $iter = $Promise_trace$excl$29.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Promise_trace$excl$29.$$p = null; if ($iter) $Promise_trace$excl$29.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; self['$there_can_be_only_one!'](); return $send(self, 'trace', Opal.to_a(args), block.$to_proc()); }, $Promise_trace$excl$29.$$arity = -1); Opal.def(self, '$there_can_be_only_one!', $Promise_there_can_be_only_one$excl$30 = function() { var self = this; if ($truthy(self.next['$any?']())) { return self.$raise($$($nesting, 'ArgumentError'), "a promise has already been chained") } else { return nil } }, $Promise_there_can_be_only_one$excl$30.$$arity = 0); Opal.def(self, '$inspect', $Promise_inspect$31 = function $$inspect() { var $a, self = this, result = nil; result = "" + "#<" + (self.$class()) + "(" + (self.$object_id()) + ")"; if ($truthy(self.next['$any?']())) { result = $rb_plus(result, "" + " >> " + (self.next.$inspect()))}; result = $rb_plus(result, (function() {if ($truthy(self['$realized?']())) { return "" + ": " + (($truthy($a = self.value) ? $a : self.error).$inspect()) + ">" } else { return ">" }; return nil; })()); return result; }, $Promise_inspect$31.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Trace'); var $nesting = [self].concat($parent_nesting), $Trace_it$32, $Trace_initialize$33; Opal.defs(self, '$it', $Trace_it$32 = function $$it(promise) { var $a, self = this, current = nil, prev = nil; current = []; if ($truthy(($truthy($a = promise['$act?']()) ? $a : promise.$prev()['$nil?']()))) { current.$push(promise.$value())}; prev = promise.$prev(); if ($truthy(prev)) { return current.$concat(self.$it(prev)) } else { return current }; }, $Trace_it$32.$$arity = 1); return (Opal.def(self, '$initialize', $Trace_initialize$33 = function $$initialize(depth, block) { var $$34, $iter = $Trace_initialize$33.$$p, $yield = $iter || nil, self = this; if ($iter) $Trace_initialize$33.$$p = null; self.depth = depth; return $send(self, Opal.find_super_dispatcher(self, 'initialize', $Trace_initialize$33, false), [$hash2(["success"], {"success": $send(self, 'proc', [], ($$34 = function(){var self = $$34.$$s || this, $a, trace = nil; trace = $$($nesting, 'Trace').$it(self).$reverse(); trace.$pop(); if ($truthy(($truthy($a = depth) ? $rb_le(depth, trace.$length()) : $a))) { trace.$shift($rb_minus(trace.$length(), depth))}; return $send(block, 'call', Opal.to_a(trace));}, $$34.$$s = self, $$34.$$arity = 0, $$34))})], null); }, $Trace_initialize$33.$$arity = 2), nil) && 'initialize'; })($nesting[0], self, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'When'); var $nesting = [self].concat($parent_nesting), $When_initialize$35, $When_each$37, $When_collect$39, $When_inject$41, $When_wait$43, $When_$gt$gt$45, $When_try$47; self.$$prototype.wait = nil; Opal.def(self, '$initialize', $When_initialize$35 = function $$initialize(promises) { var $$36, $iter = $When_initialize$35.$$p, $yield = $iter || nil, self = this; if ($iter) $When_initialize$35.$$p = null; if (promises == null) { promises = []; }; $send(self, Opal.find_super_dispatcher(self, 'initialize', $When_initialize$35, false), [], null); self.wait = []; return $send(promises, 'each', [], ($$36 = function(promise){var self = $$36.$$s || this; if (promise == null) { promise = nil; }; return self.$wait(promise);}, $$36.$$s = self, $$36.$$arity = 1, $$36)); }, $When_initialize$35.$$arity = -1); Opal.def(self, '$each', $When_each$37 = function $$each() { var $iter = $When_each$37.$$p, block = $iter || nil, $$38, self = this; if ($iter) $When_each$37.$$p = null; if ($iter) $When_each$37.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "no block given") }; return $send(self, 'then', [], ($$38 = function(values){var self = $$38.$$s || this; if (values == null) { values = nil; }; return $send(values, 'each', [], block.$to_proc());}, $$38.$$s = self, $$38.$$arity = 1, $$38)); }, $When_each$37.$$arity = 0); Opal.def(self, '$collect', $When_collect$39 = function $$collect() { var $iter = $When_collect$39.$$p, block = $iter || nil, $$40, self = this; if ($iter) $When_collect$39.$$p = null; if ($iter) $When_collect$39.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "no block given") }; return $send(self, 'then', [], ($$40 = function(values){var self = $$40.$$s || this; if (values == null) { values = nil; }; return $$($nesting, 'When').$new($send(values, 'map', [], block.$to_proc()));}, $$40.$$s = self, $$40.$$arity = 1, $$40)); }, $When_collect$39.$$arity = 0); Opal.def(self, '$inject', $When_inject$41 = function $$inject($a) { var $iter = $When_inject$41.$$p, block = $iter || nil, $post_args, args, $$42, self = this; if ($iter) $When_inject$41.$$p = null; if ($iter) $When_inject$41.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self, 'then', [], ($$42 = function(values){var self = $$42.$$s || this; if (values == null) { values = nil; }; return $send(values, 'reduce', Opal.to_a(args), block.$to_proc());}, $$42.$$s = self, $$42.$$arity = 1, $$42)); }, $When_inject$41.$$arity = -1); Opal.alias(self, "map", "collect"); Opal.alias(self, "reduce", "inject"); Opal.def(self, '$wait', $When_wait$43 = function $$wait(promise) { var $$44, self = this; if ($truthy($$($nesting, 'Promise')['$==='](promise))) { } else { promise = $$($nesting, 'Promise').$value(promise) }; if ($truthy(promise['$act?']())) { promise = promise.$then()}; self.wait['$<<'](promise); $send(promise, 'always', [], ($$44 = function(){var self = $$44.$$s || this; if (self.next == null) self.next = nil; if ($truthy(self.next['$any?']())) { return self.$try() } else { return nil }}, $$44.$$s = self, $$44.$$arity = 0, $$44)); return self; }, $When_wait$43.$$arity = 1); Opal.alias(self, "and", "wait"); Opal.def(self, '$>>', $When_$gt$gt$45 = function($a) { var $post_args, $$46, $iter = $When_$gt$gt$45.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $When_$gt$gt$45.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return $send($send(self, Opal.find_super_dispatcher(self, '>>', $When_$gt$gt$45, false), $zuper, $iter), 'tap', [], ($$46 = function(){var self = $$46.$$s || this; return self.$try()}, $$46.$$s = self, $$46.$$arity = 0, $$46)); }, $When_$gt$gt$45.$$arity = -1); return (Opal.def(self, '$try', $When_try$47 = function() { var self = this, promise = nil; if ($truthy($send(self.wait, 'all?', [], "realized?".$to_proc()))) { promise = $send(self.wait, 'find', [], "rejected?".$to_proc()); if ($truthy(promise)) { return self.$reject(promise.$error()) } else { return self.$resolve($send(self.wait, 'map', [], "value".$to_proc())) }; } else { return nil } }, $When_try$47.$$arity = 0), nil) && 'try'; })($nesting[0], self, $nesting); })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery/http"] = function(Opal) { var $$3, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2, $truthy = Opal.truthy; Opal.add_stubs(['$require', '$to_n', '$each', '$define_singleton_method', '$send', '$new', '$define_method', '$attr_reader', '$delete', '$update', '$upcase', '$succeed', '$fail', '$promise', '$parse', '$private', '$tap', '$proc', '$ok?', '$resolve', '$reject', '$from_object', '$call']); self.$require("json"); self.$require("native"); self.$require("promise"); self.$require("opal/jquery/constants"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTTP'); var $nesting = [self].concat($parent_nesting), $HTTP$1, $HTTP_setup$5, $HTTP_setup$eq$6, $HTTP_initialize$7, $HTTP_send$8, $HTTP_json$9, $HTTP_ok$ques$10, $HTTP_get_header$11, $HTTP_inspect$12, $HTTP_promise$13, $HTTP_succeed$16, $HTTP_fail$17; self.$$prototype.settings = self.$$prototype.payload = self.$$prototype.url = self.$$prototype.method = self.$$prototype.handler = self.$$prototype.json = self.$$prototype.body = self.$$prototype.ok = self.$$prototype.xhr = self.$$prototype.promise = self.$$prototype.status_code = nil; var $ = $$($nesting, 'JQUERY_SELECTOR').$to_n(); Opal.const_set($nesting[0], 'ACTIONS', ["get", "post", "put", "delete", "patch", "head"]); $send($$($nesting, 'ACTIONS'), 'each', [], ($HTTP$1 = function(action){var self = $HTTP$1.$$s || this, $$2, $$4; if (action == null) { action = nil; }; $send(self, 'define_singleton_method', [action], ($$2 = function(url, options){var self = $$2.$$s || this, $iter = $$2.$$p, block = $iter || nil; if ($iter) $$2.$$p = null;; if (url == null) { url = nil; }; if (options == null) { options = $hash2([], {}); }; return self.$new().$send(action, url, options, block);}, $$2.$$s = self, $$2.$$arity = -2, $$2)); return $send(self, 'define_method', [action], ($$4 = function(url, options){var self = $$4.$$s || this, $iter = $$4.$$p, block = $iter || nil; if ($iter) $$4.$$p = null;; if (url == null) { url = nil; }; if (options == null) { options = $hash2([], {}); }; return self.$send(action, url, options, block);}, $$4.$$s = self, $$4.$$arity = -2, $$4));}, $HTTP$1.$$s = self, $HTTP$1.$$arity = 1, $HTTP$1)); Opal.defs(self, '$setup', $HTTP_setup$5 = function $$setup() { var self = this; return $$($nesting, 'Hash').$new($.ajaxSetup()) }, $HTTP_setup$5.$$arity = 0); Opal.defs(self, '$setup=', $HTTP_setup$eq$6 = function(settings) { var self = this; return $.ajaxSetup(settings.$to_n()) }, $HTTP_setup$eq$6.$$arity = 1); self.$attr_reader("body", "error_message", "method", "status_code", "url", "xhr"); Opal.def(self, '$initialize', $HTTP_initialize$7 = function $$initialize() { var self = this; self.settings = $hash2([], {}); return (self.ok = true); }, $HTTP_initialize$7.$$arity = 0); Opal.def(self, '$send', $HTTP_send$8 = function $$send(method, url, options, block) { var $a, self = this, settings = nil, payload = nil; self.method = method; self.url = url; self.payload = options.$delete("payload"); self.handler = block; self.settings.$update(options); $a = [self.settings.$to_n(), self.payload], (settings = $a[0]), (payload = $a[1]), $a; if (typeof(payload) === 'string') { settings.data = payload; } else if (payload != nil) { settings.data = payload.$to_json(); settings.contentType = 'application/json'; } settings.url = self.url; settings.type = self.method.$upcase(); settings.success = function(data, status, xhr) { return self.$succeed(data, status, xhr); }; settings.error = function(xhr, status, error) { return self.$fail(xhr, status, error); }; $.ajax(settings); ; if ($truthy(self.handler)) { return self } else { return self.$promise() }; }, $HTTP_send$8.$$arity = 4); Opal.def(self, '$json', $HTTP_json$9 = function $$json() { var $a, self = this; return (self.json = ($truthy($a = self.json) ? $a : $$($nesting, 'JSON').$parse(self.body))) }, $HTTP_json$9.$$arity = 0); Opal.def(self, '$ok?', $HTTP_ok$ques$10 = function() { var self = this; return self.ok }, $HTTP_ok$ques$10.$$arity = 0); Opal.def(self, '$get_header', $HTTP_get_header$11 = function $$get_header(key) { var self = this; var value = self.xhr.getResponseHeader(key); return (value === null) ? nil : value; }, $HTTP_get_header$11.$$arity = 1); Opal.def(self, '$inspect', $HTTP_inspect$12 = function $$inspect() { var self = this; return "" + "#" }, $HTTP_inspect$12.$$arity = 0); self.$private(); Opal.def(self, '$promise', $HTTP_promise$13 = function $$promise() { var $$14, self = this; if ($truthy(self.promise)) { return self.promise}; return (self.promise = $send($$($nesting, 'Promise').$new(), 'tap', [], ($$14 = function(promise){var self = $$14.$$s || this, $$15; if (promise == null) { promise = nil; }; return (self.handler = $send(self, 'proc', [], ($$15 = function(res){var self = $$15.$$s || this; if (res == null) { res = nil; }; if ($truthy(res['$ok?']())) { return promise.$resolve(res) } else { return promise.$reject(res) };}, $$15.$$s = self, $$15.$$arity = 1, $$15)));}, $$14.$$s = self, $$14.$$arity = 1, $$14))); }, $HTTP_promise$13.$$arity = 0); Opal.def(self, '$succeed', $HTTP_succeed$16 = function $$succeed(data, status, xhr) { var self = this; self.body = data; self.xhr = xhr; self.status_code = xhr.status; if (typeof(data) === 'object') { self.json = $$($nesting, 'JSON').$from_object(data); } ; if ($truthy(self.handler)) { return self.handler.$call(self) } else { return nil }; }, $HTTP_succeed$16.$$arity = 3); return (Opal.def(self, '$fail', $HTTP_fail$17 = function $$fail(xhr, status, error) { var self = this; self.body = xhr.responseText; self.xhr = xhr; self.status_code = xhr.status; ; self.ok = false; if ($truthy(self.handler)) { return self.handler.$call(self) } else { return nil }; }, $HTTP_fail$17.$$arity = 3), nil) && 'fail'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery/kernel"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; return (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_alert$1; Opal.def(self, '$alert', $Kernel_alert$1 = function $$alert(msg) { var self = this; alert(msg); return nil; }, $Kernel_alert$1.$$arity = 1) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["opal/jquery"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$==', '$require']); if ($$($nesting, 'RUBY_ENGINE')['$==']("opal")) { self.$require("opal/jquery/window"); self.$require("opal/jquery/document"); self.$require("opal/jquery/element"); self.$require("opal/jquery/event"); self.$require("opal/jquery/http"); return self.$require("opal/jquery/kernel"); } else { return nil } }; /* Generated by Opal 1.0.3 */ Opal.modules["opal-jquery"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$require']); return self.$require("opal/jquery") }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/utils"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $module = Opal.module, $send = Opal.send, $truthy = Opal.truthy; Opal.add_stubs(['$size', '$min', '$scan', '$gsub', '$proc', '$===', '$merge', '$to_proc', '$merge!']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $parent_nesting) { var self = $module($base, 'Utils'); var $nesting = [self].concat($parent_nesting), $Utils_heredoc$1, $Utils_deep_merge$2, $Utils_deep_merge$excl$4; Opal.defs(self, '$heredoc', $Utils_heredoc$1 = function $$heredoc(string) { var self = this, indent = nil; indent = (function() { try { return string.$scan(/^[ \t]*(?=\S)/).$min().$size() } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return 0 } finally { Opal.pop_exception() } } else { throw $err; } }})(); return string.$gsub(new RegExp("" + "^[ \\t]{" + (indent) + "}"), ""); }, $Utils_heredoc$1.$$arity = 1); Opal.defs(self, '$deep_merge', $Utils_deep_merge$2 = function $$deep_merge(a, b) { var $$3, self = this, merger = nil; merger = $send(self, 'proc', [], ($$3 = function(key, v1, v2){var self = $$3.$$s || this, $a; if (key == null) { key = nil; }; if (v1 == null) { v1 = nil; }; if (v2 == null) { v2 = nil; }; if ($truthy(($truthy($a = $$($nesting, 'Hash')['$==='](v1)) ? $$($nesting, 'Hash')['$==='](v2) : $a))) { return $send(v1, 'merge', [v2], merger.$to_proc()) } else { return v2 };}, $$3.$$s = self, $$3.$$arity = 3, $$3)); return $send(a, 'merge', [b], merger.$to_proc()); }, $Utils_deep_merge$2.$$arity = 2); Opal.defs(self, '$deep_merge!', $Utils_deep_merge$excl$4 = function(a, b) { var $$5, self = this, merger = nil; merger = $send(self, 'proc', [], ($$5 = function(key, v1, v2){var self = $$5.$$s || this, $a; if (key == null) { key = nil; }; if (v1 == null) { v1 = nil; }; if (v2 == null) { v2 = nil; }; if ($truthy(($truthy($a = $$($nesting, 'Hash')['$==='](v1)) ? $$($nesting, 'Hash')['$==='](v2) : $a))) { $send(v1, 'merge!', [v2], merger.$to_proc()); return v1; } else { return v2 };}, $$5.$$s = self, $$5.$$arity = 3, $$5)); return $send(a, 'merge!', [b], merger.$to_proc()); }, $Utils_deep_merge$excl$4.$$arity = 2); })($nesting[0], $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/helpers"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy; Opal.add_stubs(['$define_method', '$instance_exec', '$to_proc', '$do', '$defhelper', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting), $Element_defhelper$1, $Element_defhelper$excl$3; Opal.defs(self, '$defhelper', $Element_defhelper$1 = function $$defhelper(name) { var $iter = $Element_defhelper$1.$$p, block = $iter || nil, $$2, self = this; if ($iter) $Element_defhelper$1.$$p = null; if ($iter) $Element_defhelper$1.$$p = null;; return $send(self, 'define_method', [name], ($$2 = function($a){var self = $$2.$$s || this, $iter = $$2.$$p, body = $iter || nil, $post_args, args; if ($iter) $$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; $send(self, 'instance_exec', Opal.to_a(args), block.$to_proc()); if ($truthy(body)) { $send(self, 'do', [], body.$to_proc())}; return self;}, $$2.$$s = self, $$2.$$arity = -1, $$2)); }, $Element_defhelper$1.$$arity = 1); return (Opal.defs(self, '$defhelper!', $Element_defhelper$excl$3 = function(name, attribute) { var $$4, self = this; if (attribute == null) { attribute = name; }; return $send(self, 'defhelper', ["" + (name) + "!"], ($$4 = function(){var self = $$4.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; $writer = [attribute, true]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$4.$$s = self, $$4.$$arity = 0, $$4)); }, $Element_defhelper$excl$3.$$arity = -2), nil) && 'defhelper!'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/a"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$to_s', '$[]=', '$-', '$defhelper!', '$<<']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'A'); var $nesting = [self].concat($parent_nesting), $A$1, $A$3; $send($hash2(["href", "url", "rel", "relative", "target", "type", "lang", "language", "media"], {"href": "href", "url": "href", "rel": "rel", "relative": "rel", "target": "target", "type": "type", "lang": "hreflang", "language": "hreflang", "media": "media"}), 'each', [], ($A$1 = function(name, attribute){var self = $A$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $A$1.$$s = self, $A$1.$$arity = 2, $A$1)); self['$defhelper!']("download"); self['$defhelper!']("ping"); return $send(self, 'defhelper', ["text"], ($A$3 = function(string){var self = $A$3.$$s || this; if (string == null) { string = nil; }; return self['$<<'](string);}, $A$3.$$s = self, $A$3.$$arity = 1, $A$3)); })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/base"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$to_s', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Base'); var $nesting = [self].concat($parent_nesting), $Base$1; return $send($hash2(["href", "url", "target"], {"href": "href", "url": "href", "target": "target"}), 'each', [], ($Base$1 = function(name, attribute){var self = $Base$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Base$1.$$s = self, $Base$1.$$arity = 2, $Base$1)) })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/blockquote"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$defhelper', '$to_s', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Blockquote'); var $nesting = [self].concat($parent_nesting), $Blockquote$1; return $send(self, 'defhelper', ["cite"], ($Blockquote$1 = function(value){var self = $Blockquote$1.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = ["cite", value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $Blockquote$1.$$s = self, $Blockquote$1.$$arity = 1, $Blockquote$1)) })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/button"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$to_s', '$[]=', '$-', '$defhelper!']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Button'); var $nesting = [self].concat($parent_nesting), $Button$1; $send($hash2(["form", "name", "type", "value", "action", "encoding", "method", "target"], {"form": "form", "name": "name", "type": "type", "value": "value", "action": "formaction", "encoding": "formenctype", "method": "formmethod", "target": "formtarget"}), 'each', [], ($Button$1 = function(name, attributes){var self = $Button$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attributes == null) { attributes = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Button$1.$$s = self, $Button$1.$$arity = 2, $Button$1)); self['$defhelper!']("autofocus"); return self['$defhelper!']("disabled"); })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/canvas"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$to_s', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Canvas'); var $nesting = [self].concat($parent_nesting), $Canvas$1; return $send($hash2(["width", "height"], {"width": "width", "height": "height"}), 'each', [], ($Canvas$1 = function(name, attribute){var self = $Canvas$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Canvas$1.$$s = self, $Canvas$1.$$arity = 2, $Canvas$1)) })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/embed"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Embed'); var $nesting = [self].concat($parent_nesting), $Embed$1; return $send($hash2(["type", "height", "width"], {"type": "type", "height": "height", "width": "width"}), 'each', [], ($Embed$1 = function(name, attribute){var self = $Embed$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Embed$1.$$s = self, $Embed$1.$$arity = 2, $Embed$1)) })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/img"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$to_s', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Img'); var $nesting = [self].concat($parent_nesting), $Img$1, $Img$3; $send($hash2(["src", "url", "alt", "description", "height", "width", "map"], {"src": "src", "url": "src", "alt": "alt", "description": "alt", "height": "height", "width": "width", "map": "usemap"}), 'each', [], ($Img$1 = function(name, attribute){var self = $Img$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Img$1.$$s = self, $Img$1.$$arity = 2, $Img$1)); return $send(self, 'defhelper', ["map!"], ($Img$3 = function(){var self = $Img$3.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; $writer = ["ismap", true]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $Img$3.$$s = self, $Img$3.$$arity = 0, $Img$3)); })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/input"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Input'); var $nesting = [self].concat($parent_nesting), $Input$1; return $send($hash2(["type", "name", "value", "size", "place_holder", "read_only", "required", "limit"], {"type": "type", "name": "name", "value": "value", "size": "size", "place_holder": "placeholder", "read_only": "readonly", "required": "required", "limit": "maxlength"}), 'each', [], ($Input$1 = function(name, attribute){var self = $Input$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Input$1.$$s = self, $Input$1.$$arity = 2, $Input$1)) })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/link"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$to_s', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Link'); var $nesting = [self].concat($parent_nesting), $Link$1; return $send($hash2(["cross_origin", "href", "href_lang", "media", "rel", "sizes", "type"], {"cross_origin": "crossorigin", "href": "href", "href_lang": "hreflang", "media": "media", "rel": "rel", "sizes": "sizes", "type": "type"}), 'each', [], ($Link$1 = function(name, attribute){var self = $Link$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Link$1.$$s = self, $Link$1.$$arity = 2, $Link$1)) })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/object"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$each', '$defhelper', '$[]=', '$-']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Object'); var $nesting = [self].concat($parent_nesting), $Object$1; return $send($hash2(["type", "data", "name", "height", "width"], {"type": "type", "data": "data", "name": "name", "height": "height", "width": "width"}), 'each', [], ($Object$1 = function(name, attribute){var self = $Object$1.$$s || this, $$2; if (name == null) { name = nil; }; if (attribute == null) { attribute = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Object$1.$$s = self, $Object$1.$$arity = 2, $Object$1)) })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/option"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$each', '$defhelper', '$[]=', '$-', '$defhelper!']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Option'); var $nesting = [self].concat($parent_nesting), $Option$1; $send(["label", "value"], 'each', [], ($Option$1 = function(name){var self = $Option$1.$$s || this, $$2; if (name == null) { name = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Option$1.$$s = self, $Option$1.$$arity = 1, $Option$1)); self['$defhelper!']("disabled"); return self['$defhelper!']("selected"); })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/optgroup"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$each', '$defhelper', '$[]=', '$-', '$defhelper!']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Optgroup'); var $nesting = [self].concat($parent_nesting), $Optgroup$1; $send(["label", "value"], 'each', [], ($Optgroup$1 = function(name){var self = $Optgroup$1.$$s || this, $$2; if (name == null) { name = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Optgroup$1.$$s = self, $Optgroup$1.$$arity = 1, $Optgroup$1)); self['$defhelper!']("disabled"); return self['$defhelper!']("selected"); })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/select"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$each', '$defhelper', '$[]=', '$-', '$defhelper!']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Select'); var $nesting = [self].concat($parent_nesting), $Select$1; $send(["form", "name", "size"], 'each', [], ($Select$1 = function(name){var self = $Select$1.$$s || this, $$2; if (name == null) { name = nil; }; return $send(self, 'defhelper', [name], ($$2 = function(value){var self = $$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = [name, value]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 1, $$2));}, $Select$1.$$s = self, $Select$1.$$arity = 1, $Select$1)); self['$defhelper!']("auto_focus", "autofocus"); self['$defhelper!']("disabled"); return self['$defhelper!']("required"); })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element/td"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$defhelper', '$to_s', '$[]=', '$-', '$join']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Td'); var $nesting = [self].concat($parent_nesting), $Td$1, $Td$2, $Td$3; $send(self, 'defhelper', ["columns"], ($Td$1 = function(value){var self = $Td$1.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = ["colspan", value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $Td$1.$$s = self, $Td$1.$$arity = 1, $Td$1)); $send(self, 'defhelper', ["rows"], ($Td$2 = function(value){var self = $Td$2.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (value == null) { value = nil; }; $writer = ["rowspan", value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $Td$2.$$s = self, $Td$2.$$arity = 1, $Td$2)); return $send(self, 'defhelper', ["headers"], ($Td$3 = function($a){var self = $Td$3.$$s || this, $post_args, args, $writer = nil; if (self.attributes == null) self.attributes = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; $writer = ["headers", args.$join(" ")]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $Td$3.$$s = self, $Td$3.$$arity = -1, $Td$3)); })($nesting[0], self, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html/element"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2, $send = Opal.send, $truthy = Opal.truthy, $range = Opal.range; Opal.add_stubs(['$require', '$==', '$capitalize', '$const_defined?', '$new', '$const_get', '$each', '$to_proc', '$<<', '$end_with?', '$to_s', '$[]', '$[]=', '$-', '$===', '$has_key?', '$unshift', '$|', '$split', '$delete', '$to_a', '$deep_merge!', '$>>', '$extend!', '$pop', '$join', '$heredoc', '$defhelper', '$map', '$empty?', '$upcase', '$inspect']); self.$require("paggio/html/element/a"); self.$require("paggio/html/element/base"); self.$require("paggio/html/element/blockquote"); self.$require("paggio/html/element/button"); self.$require("paggio/html/element/canvas"); self.$require("paggio/html/element/embed"); self.$require("paggio/html/element/img"); self.$require("paggio/html/element/input"); self.$require("paggio/html/element/link"); self.$require("paggio/html/element/object"); self.$require("paggio/html/element/option"); self.$require("paggio/html/element/optgroup"); self.$require("paggio/html/element/select"); self.$require("paggio/html/element/td"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting), $Element_new$1, $Element_initialize$2, $Element_each$3, $Element_$lt$lt$4, $Element_method_missing$5, $Element_$$$6, $Element_do$7, $Element_$gt$gt$8, $Element$9, $Element$11, $Element_inspect$13; self.$$prototype.children = self.$$prototype.attributes = self.$$prototype.class_names = self.$$prototype.owner = self.$$prototype.name = nil; Opal.defs(self, '$new', $Element_new$1 = function(owner, name, attributes) { var $iter = $Element_new$1.$$p, $yield = $iter || nil, self = this, const$ = nil, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Element_new$1.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if (attributes == null) { attributes = $hash2([], {}); }; if (self['$==']($$($nesting, 'Element'))) { } else { return $send(self, Opal.find_super_dispatcher(self, 'new', $Element_new$1, false, self.$$class.$$prototype), $zuper, $iter) }; const$ = name.$capitalize(); if ($truthy(self['$const_defined?'](const$))) { return self.$const_get(const$).$new(owner, name, attributes) } else { return $send(self, Opal.find_super_dispatcher(self, 'new', $Element_new$1, false, self.$$class.$$prototype), $zuper, $iter) }; }, $Element_new$1.$$arity = -3); Opal.def(self, '$initialize', $Element_initialize$2 = function $$initialize(owner, name, attributes) { var self = this; if (attributes == null) { attributes = $hash2([], {}); }; self.owner = owner; self.name = name; self.attributes = attributes; self.children = []; return (self.class_names = []); }, $Element_initialize$2.$$arity = -3); Opal.def(self, '$each', $Element_each$3 = function $$each() { var $iter = $Element_each$3.$$p, block = $iter || nil, self = this; if ($iter) $Element_each$3.$$p = null; if ($iter) $Element_each$3.$$p = null;; return $send(self.children, 'each', [], block.$to_proc()); }, $Element_each$3.$$arity = 0); Opal.def(self, '$<<', $Element_$lt$lt$4 = function(what) { var self = this; self.children['$<<'](what); return self; }, $Element_$lt$lt$4.$$arity = 1); Opal.def(self, '$method_missing', $Element_method_missing$5 = function $$method_missing(name, content) { var $iter = $Element_method_missing$5.$$p, block = $iter || nil, $a, self = this, $writer = nil; if ($iter) $Element_method_missing$5.$$p = null; if ($iter) $Element_method_missing$5.$$p = null;; if (content == null) { content = nil; }; if ($truthy(name.$to_s()['$end_with?']("!"))) { $writer = ["id", name['$[]']($range(0, -2, false))]; $send(self.attributes, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; } else { self.class_names['$<<'](name) }; if ($truthy($$$('::', 'Hash')['$==='](content))) { if ($truthy(($truthy($a = content['$has_key?']("class")) ? $a : content['$has_key?']("classes")))) { $send(self.class_names, 'unshift', Opal.to_a(content.$delete("class").$to_s().$split()['$|'](content.$delete("classes").$to_a())))}; $$$($$$('::', 'Paggio'), 'Utils')['$deep_merge!'](self.attributes, content); } else if ($truthy(content)) { self['$>>'](content)}; if ($truthy(block)) { $send(self.owner, 'extend!', [self], block.$to_proc())}; return self; }, $Element_method_missing$5.$$arity = -2); Opal.def(self, '$[]', $Element_$$$6 = function($a) { var $post_args, names, self = this, last = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; if ($truthy((last = self.class_names.$pop()))) { self.class_names['$<<']([last].concat(Opal.to_a(names)).$join("-"))}; return self; }, $Element_$$$6.$$arity = -1); Opal.def(self, '$do', $Element_do$7 = function() { var $iter = $Element_do$7.$$p, block = $iter || nil, self = this; if ($iter) $Element_do$7.$$p = null; if ($iter) $Element_do$7.$$p = null;; $send(self.owner, 'extend!', [self], block.$to_proc()); return self; }, $Element_do$7.$$arity = 0); Opal.def(self, '$>>', $Element_$gt$gt$8 = function(content) { var self = this; self['$<<']($$$($$$('::', 'Paggio'), 'Utils').$heredoc(content.$to_s())); return self; }, $Element_$gt$gt$8.$$arity = 1); $send(self, 'defhelper', ["style"], ($Element$9 = function(hash){var self = $Element$9.$$s || this, $$10, $writer = nil; if (self.attributes == null) self.attributes = nil; if (hash == null) { hash = nil; }; $writer = ["style", $send(hash, 'map', [], ($$10 = function(name, value){var self = $$10.$$s || this; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return "" + (name) + ": " + (value);}, $$10.$$s = self, $$10.$$arity = 2, $$10)).$join(";")]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $Element$9.$$s = self, $Element$9.$$arity = 1, $Element$9)); $send(self, 'defhelper', ["data"], ($Element$11 = function(hash){var self = $Element$11.$$s || this, $$12; if (hash == null) { hash = nil; }; return $send(hash, 'each', [], ($$12 = function(name, value){var self = $$12.$$s || this, $writer = nil; if (self.attributes == null) self.attributes = nil; if (name == null) { name = nil; }; if (value == null) { value = nil; }; $writer = ["" + "data-" + (name), value.$to_s()]; $send(self.attributes, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$12.$$s = self, $$12.$$arity = 2, $$12));}, $Element$11.$$s = self, $Element$11.$$arity = 1, $Element$11)); return (Opal.def(self, '$inspect', $Element_inspect$13 = function $$inspect() { var self = this; if ($truthy(self.children['$empty?']())) { return "" + "#" } else { return "" + "#" } }, $Element_inspect$13.$$arity = 0), nil) && 'inspect'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/html"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $range = Opal.range; Opal.add_stubs(['$require', '$attr_reader', '$raise', '$==', '$arity', '$instance_exec', '$to_proc', '$call', '$<<', '$first', '$===', '$instance_eval', '$each', '$end_with?', '$to_s', '$empty?', '$heredoc', '$shift', '$new', '$[]', '$inspect']); self.$require("paggio/html/helpers"); self.$require("paggio/html/element"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting), $HTML_initialize$1, $HTML_$lt$lt$2, $HTML_root$excl$3, $HTML_roots$excl$4, $HTML_element$excl$5, $HTML_extend$excl$6, $HTML_each$8, $HTML_method_missing$9, $HTML_inspect$11; self.$$prototype.current = self.$$prototype.roots = self.$$prototype.version = nil; self.$attr_reader("version"); Opal.def(self, '$initialize', $HTML_initialize$1 = function $$initialize(version) { var $iter = $HTML_initialize$1.$$p, block = $iter || nil, self = this; if ($iter) $HTML_initialize$1.$$p = null; if ($iter) $HTML_initialize$1.$$p = null;; if (version == null) { version = 5; }; if ($truthy(block)) { } else { $$$('::', 'Kernel').$raise($$$('::', 'ArgumentError'), "no block given") }; self.version = version; self.roots = []; self.current = nil; if (block.$arity()['$=='](0)) { return $send(self, 'instance_exec', [], block.$to_proc()) } else { return block.$call(self) }; }, $HTML_initialize$1.$$arity = -1); Opal.def(self, '$<<', $HTML_$lt$lt$2 = function(what) { var $a, self = this; return ($truthy($a = self.current) ? $a : self.roots)['$<<'](what) }, $HTML_$lt$lt$2.$$arity = 1); Opal.def(self, '$root!', $HTML_root$excl$3 = function() { var self = this; return self.roots.$first() }, $HTML_root$excl$3.$$arity = 0); Opal.def(self, '$roots!', $HTML_roots$excl$4 = function() { var self = this; return self.roots }, $HTML_roots$excl$4.$$arity = 0); Opal.def(self, '$element!', $HTML_element$excl$5 = function() { var self = this; return self.current }, $HTML_element$excl$5.$$arity = 0); Opal.def(self, '$extend!', $HTML_extend$excl$6 = function(element) { var $iter = $HTML_extend$excl$6.$$p, block = $iter || nil, $a, $$7, self = this, old = nil, result = nil; if ($iter) $HTML_extend$excl$6.$$p = null; if ($iter) $HTML_extend$excl$6.$$p = null;; if (element == null) { element = nil; }; $a = [self.current, element], (old = $a[0]), (self.current = $a[1]), $a; result = block.$call(self); if ($truthy($$$('::', 'String')['$==='](result))) { $send(self.current, 'instance_eval', [], ($$7 = function(){var self = $$7.$$s || this; return (self.inner_html = result)}, $$7.$$s = self, $$7.$$arity = 0, $$7))}; self.current = old; return self; }, $HTML_extend$excl$6.$$arity = -1); Opal.def(self, '$each', $HTML_each$8 = function $$each() { var $iter = $HTML_each$8.$$p, block = $iter || nil, self = this; if ($iter) $HTML_each$8.$$p = null; if ($iter) $HTML_each$8.$$p = null;; return $send(self.roots, 'each', [], block.$to_proc()); }, $HTML_each$8.$$arity = 0); Opal.def(self, '$method_missing', $HTML_method_missing$9 = function $$method_missing(name, $a) { var $iter = $HTML_method_missing$9.$$p, block = $iter || nil, $post_args, args, $b, $$10, self = this, content = nil, element = nil, parent = nil, result = nil, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $HTML_method_missing$9.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if ($iter) $HTML_method_missing$9.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(name.$to_s()['$end_with?']("!"))) { return $send(self, Opal.find_super_dispatcher(self, 'method_missing', $HTML_method_missing$9, false), $zuper, $iter)}; if ($truthy(($truthy($b = args['$empty?']()) ? $b : $$$('::', 'Hash')['$==='](args.$first())))) { } else { content = $$$($$$('::', 'Paggio'), 'Utils').$heredoc(args.$shift().$to_s()) }; element = $send($$($nesting, 'Element'), 'new', [self, name].concat(Opal.to_a(args))); if ($truthy(content)) { element['$<<'](content)}; if ($truthy(block)) { parent = self.current; self.current = element; result = block.$call(self); self.current = parent; if ($truthy($$$('::', 'String')['$==='](result))) { $send(element, 'instance_eval', [], ($$10 = function(){var self = $$10.$$s || this; return (self.inner_html = result)}, $$10.$$s = self, $$10.$$arity = 0, $$10))};}; self['$<<'](element); return element; }, $HTML_method_missing$9.$$arity = -2); return (Opal.def(self, '$inspect', $HTML_inspect$11 = function $$inspect() { var self = this; if ($truthy(self.roots['$empty?']())) { return "" + "#" } else { return "" + "#" } }, $HTML_inspect$11.$$arity = 0), nil) && 'inspect'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/css/unit"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } function $rb_divide(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs / rhs : lhs['$/'](rhs); } var $$23, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy; Opal.add_stubs(['$map', '$to_proc', '$attr_reader', '$===', '$respond_to?', '$raise', '$class', '$to_u', '$new', '$==', '$convert', '$type', '$number', '$hash', '$each', '$define_method', '$+', '$compatible?', '$-', '$*', '$/', '$to_i', '$to_f', '$private', '$include?', '$class_eval', '$old_percent', '$match', '$[]', '$__send__', '$downcase']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CSS'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Unit'); var $nesting = [self].concat($parent_nesting), $Unit_initialize$1, $Unit_coerce$2, $Unit_$eq_eq$3, $Unit_$eq_eq_eq$4, $Unit_hash$5, $Unit$6, $Unit_$plus$8, $Unit_$minus$9, $Unit_$$10, $Unit_$slash$11, $Unit_$minus$$12, $Unit_$plus$$13, $Unit_to_i$14, $Unit_to_f$15, $Unit_to_u$16, $Unit_to_s$17, $Unit_compatible$ques$18, $Unit_convert$19; self.$$prototype.type = self.$$prototype.number = nil; Opal.const_set($nesting[0], 'TYPES', $send(["em", "ex", "ch", "rem", "vh", "vw", "vmin", "vmax", "px", "mm", "cm", "in", "pt", "pc", "s", "deg"], 'map', [], "to_sym".$to_proc())); Opal.const_set($nesting[0], 'COMPATIBLE', $send(["in", "pt", "mm", "cm", "px", "pc"], 'map', [], "to_sym".$to_proc())); self.$attr_reader("type", "number"); Opal.def(self, '$initialize', $Unit_initialize$1 = function $$initialize(number, type) { var self = this; self.number = number; return (self.type = type); }, $Unit_initialize$1.$$arity = 2); Opal.def(self, '$coerce', $Unit_coerce$2 = function $$coerce(other) { var self = this; return [self, other] }, $Unit_coerce$2.$$arity = 1); Opal.def(self, '$==', $Unit_$eq_eq$3 = function(other) { var self = this; if ($truthy($$($nesting, 'Unit')['$==='](other))) { } else { if ($truthy(other['$respond_to?']("to_u"))) { } else { self.$raise($$($nesting, 'TypeError'), "" + "no implicit conversion of " + (other.$class()) + " into Unit") }; other = other.$to_u(); }; if ($truthy($$($nesting, 'Unit')['$==='](other))) { } else { other = $$($nesting, 'Unit').$new(other, self.type) }; return self.number['$=='](self.$convert(other, self.type)); }, $Unit_$eq_eq$3.$$arity = 1); Opal.def(self, '$===', $Unit_$eq_eq_eq$4 = function(other) { var $a, self = this; return (($a = self.type['$=='](other.$type())) ? self.number['$=='](other.$number()) : self.type['$=='](other.$type())) }, $Unit_$eq_eq_eq$4.$$arity = 1); Opal.alias(self, "eql?", "=="); Opal.def(self, '$hash', $Unit_hash$5 = function $$hash() { var self = this; return [self.number, self.type].$hash() }, $Unit_hash$5.$$arity = 0); $send($$($nesting, 'TYPES'), 'each', [], ($Unit$6 = function(name){var self = $Unit$6.$$s || this, $$7; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$7 = function(){var self = $$7.$$s || this; return $$($nesting, 'Unit').$new(self.$convert(self, name), name)}, $$7.$$s = self, $$7.$$arity = 0, $$7));}, $Unit$6.$$s = self, $Unit$6.$$arity = 1, $Unit$6)); Opal.def(self, '$+', $Unit_$plus$8 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Unit')['$==='](other))) { } else { return $$($nesting, 'Unit').$new($rb_plus(self.number, other), self.type) }; if (self.type['$=='](other.$type())) { return $$($nesting, 'Unit').$new($rb_plus(self.number, other.$number()), self.type) } else if ($truthy(($truthy($a = self['$compatible?'](self)) ? self['$compatible?'](other) : $a))) { return $$($nesting, 'Unit').$new($rb_plus(self.number, self.$convert(other, self.type)), self.type) } else { return self.$raise($$($nesting, 'ArgumentError'), "" + (other.$type()) + " isn't compatible with " + (self.type)) }; }, $Unit_$plus$8.$$arity = 1); Opal.def(self, '$-', $Unit_$minus$9 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Unit')['$==='](other))) { } else { return $$($nesting, 'Unit').$new($rb_minus(self.number, other), self.type) }; if (self.type['$=='](other.$type())) { return $$($nesting, 'Unit').$new($rb_minus(self.number, other.$number()), self.type) } else if ($truthy(($truthy($a = self['$compatible?'](self)) ? self['$compatible?'](other) : $a))) { return $$($nesting, 'Unit').$new($rb_minus(self.number, self.$convert(other, self.type)), self.type) } else { return self.$raise($$($nesting, 'ArgumentError'), "" + (other.$type()) + " isn't compatible with " + (self.type)) }; }, $Unit_$minus$9.$$arity = 1); Opal.def(self, '$*', $Unit_$$10 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Unit')['$==='](other))) { } else { return $$($nesting, 'Unit').$new($rb_times(self.number, other), self.type) }; if (self.type['$=='](other.$type())) { return $$($nesting, 'Unit').$new($rb_times(self.number, other.$number()), self.type) } else if ($truthy(($truthy($a = self['$compatible?'](self)) ? self['$compatible?'](other) : $a))) { return $$($nesting, 'Unit').$new($rb_times(self.number, self.$convert(other, self.type)), self.type) } else { return self.$raise($$($nesting, 'ArgumentError'), "" + (other.$type()) + " isn't compatible with " + (self.type)) }; }, $Unit_$$10.$$arity = 1); Opal.def(self, '$/', $Unit_$slash$11 = function(other) { var $a, self = this; if ($truthy($$($nesting, 'Unit')['$==='](other))) { } else { return $$($nesting, 'Unit').$new($rb_divide(self.number, other), self.type) }; if (self.type['$=='](other.$type())) { return $$($nesting, 'Unit').$new($rb_divide(self.number, other.$number()), self.type) } else if ($truthy(($truthy($a = self['$compatible?'](self)) ? self['$compatible?'](other) : $a))) { return $$($nesting, 'Unit').$new($rb_divide(self.number, self.$convert(other, self.type)), self.type) } else { return self.$raise($$($nesting, 'ArgumentError'), "" + (other.$type()) + " isn't compatible with " + (self.type)) }; }, $Unit_$slash$11.$$arity = 1); Opal.def(self, '$-@', $Unit_$minus$$12 = function() { var self = this; return $$($nesting, 'Unit').$new($rb_times(self.number, -1), self.type) }, $Unit_$minus$$12.$$arity = 0); Opal.def(self, '$+@', $Unit_$plus$$13 = function() { var self = this; return $$($nesting, 'Unit').$new(self.number, self.type) }, $Unit_$plus$$13.$$arity = 0); Opal.def(self, '$to_i', $Unit_to_i$14 = function $$to_i() { var self = this; return self.number.$to_i() }, $Unit_to_i$14.$$arity = 0); Opal.def(self, '$to_f', $Unit_to_f$15 = function $$to_f() { var self = this; return self.number.$to_f() }, $Unit_to_f$15.$$arity = 0); Opal.def(self, '$to_u', $Unit_to_u$16 = function $$to_u() { var self = this; return self }, $Unit_to_u$16.$$arity = 0); Opal.def(self, '$to_s', $Unit_to_s$17 = function $$to_s() { var self = this; return "" + (self.number) + (self.type) }, $Unit_to_s$17.$$arity = 0); Opal.alias(self, "to_str", "to_s"); Opal.alias(self, "inspect", "to_s"); self.$private(); Opal.def(self, '$compatible?', $Unit_compatible$ques$18 = function(unit) { var self = this; return $$($nesting, 'COMPATIBLE')['$include?'](unit.$type()) }, $Unit_compatible$ques$18.$$arity = 1); return (Opal.def(self, '$convert', $Unit_convert$19 = function $$convert(unit, type) { var self = this, value = nil, px = nil, $case = nil; value = unit.$number(); if (unit.$type()['$=='](type)) { return value}; px = (function() {$case = unit.$type(); if ("in"['$===']($case)) {return $rb_times(value, 96)} else if ("pt"['$===']($case)) {return $rb_divide($rb_times(value, 4.0), 3.0)} else if ("pc"['$===']($case)) {return $rb_divide($rb_times($rb_divide(value, 12), 4.0), 3.0)} else if ("mm"['$===']($case)) {return $rb_times(value, 3.77953)} else if ("cm"['$===']($case)) {return $rb_times($rb_times(value, 10), 3.77953)} else if ("px"['$===']($case)) {return value} else { return nil }})(); return (function() {$case = type; if ("in"['$===']($case)) {return $rb_divide(px, 96.0)} else if ("pt"['$===']($case)) {return $rb_divide($rb_divide(px, 4.0), 3.0)} else if ("pc"['$===']($case)) {return $rb_divide($rb_divide($rb_times(px, 12), 4.0), 3.0)} else if ("mm"['$===']($case)) {return $rb_divide(px, 3.77953)} else if ("cm"['$===']($case)) {return $rb_divide($rb_divide(px, 10), 3.77953)} else if ("px"['$===']($case)) {return px} else { return nil }})(); }, $Unit_convert$19.$$arity = 2), nil) && 'convert'; })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Numeric'); var $nesting = [self].concat($parent_nesting), $Numeric$20, $Numeric_to_u$22; $send($$$($$$($$$($$($nesting, 'Paggio'), 'CSS'), 'Unit'), 'TYPES'), 'each', [], ($Numeric$20 = function(name){var self = $Numeric$20.$$s || this, $$21; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$21 = function(){var self = $$21.$$s || this; return $$$($$$($$($nesting, 'Paggio'), 'CSS'), 'Unit').$new(self, name)}, $$21.$$s = self, $$21.$$arity = 0, $$21));}, $Numeric$20.$$s = self, $Numeric$20.$$arity = 1, $Numeric$20)); return (Opal.def(self, '$to_u', $Numeric_to_u$22 = function $$to_u() { var self = this; return self }, $Numeric_to_u$22.$$arity = 0), nil) && 'to_u'; })($nesting[0], null, $nesting); $send([$$($nesting, 'Fixnum'), $$($nesting, 'Float')], 'each', [], ($$23 = function(klass){var self = $$23.$$s || this, $$24; if (klass == null) { klass = nil; }; return $send(klass, 'class_eval', [], ($$24 = function(){var self = $$24.$$s || this, $percent$25; Opal.alias(self, "old_percent", "%"); return (Opal.def(self, '$%', $percent$25 = function(other) { var self = this; if (other == null) { other = nil; }; if ($truthy(other)) { return self.$old_percent(other) } else { return $$$($$$($$($nesting, 'Paggio'), 'CSS'), 'Unit').$new(self, "%") }; }, $percent$25.$$arity = -1), nil) && '%';}, $$24.$$s = self, $$24.$$arity = 0, $$24));}, $$23.$$s = self, $$23.$$arity = 1, $$23)); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String_to_u$26; return (Opal.def(self, '$to_u', $String_to_u$26 = function $$to_u() { var self = this, matches = nil, value = nil, unit = nil; if ($truthy((matches = self.$match(/^([\d+.]+)(.+)?$/)))) { value = matches['$[]'](1).$to_f(); if ($truthy((unit = matches['$[]'](2)))) { return value.$__send__(unit.$downcase()) } else { return value }; } else { return 0 } }, $String_to_u$26.$$arity = 0), nil) && 'to_u' })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NilClass'); var $nesting = [self].concat($parent_nesting), $NilClass_to_u$27; return (Opal.def(self, '$to_u', $NilClass_to_u$27 = function $$to_u() { var self = this; return 0 }, $NilClass_to_u$27.$$arity = 0), nil) && 'to_u' })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/css/color"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$each', '$map', '$to_proc', '$define_method', '$new']); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CSS'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Color'); var $nesting = [self].concat($parent_nesting), $Color_initialize$1; return (Opal.def(self, '$initialize', $Color_initialize$1 = function $$initialize(value, type) { var self = this; self.internal = value; return (self.type = type); }, $Color_initialize$1.$$arity = 2), nil) && 'initialize' })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String$2; return $send($send(["rgb", "rgba", "hsl", "hsla"], 'map', [], "to_sym".$to_proc()), 'each', [], ($String$2 = function(name){var self = $String$2.$$s || this, $$3; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$3 = function(){var self = $$3.$$s || this; return $$$($$$($$($nesting, 'Paggio'), 'CSS'), 'Color').$new(self, name)}, $$3.$$s = self, $$3.$$arity = 0, $$3));}, $String$2.$$s = self, $String$2.$$arity = 1, $String$2)) })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Array'); var $nesting = [self].concat($parent_nesting), $Array$4; return $send($send(["rgb", "rgba", "hsl", "hsla"], 'map', [], "to_sym".$to_proc()), 'each', [], ($Array$4 = function(name){var self = $Array$4.$$s || this, $$5; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$5 = function(){var self = $$5.$$s || this; return $$$($$$($$($nesting, 'Paggio'), 'CSS'), 'Color').$new(self, name)}, $$5.$$s = self, $$5.$$arity = 0, $$5));}, $Array$4.$$s = self, $Array$4.$$arity = 1, $Array$4)) })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/css/definition"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $range = Opal.range, $hash2 = Opal.hash2; Opal.add_stubs(['$new', '$==', '$arity', '$instance_exec', '$to_proc', '$call', '$empty?', '$each', '$inspect', '$to_s', '$define_method', '$a', '$===', '$first', '$>', '$length', '$raise', '$style', '$name', '$value', '$[]', '$join', '$map', '$to_i', '$*', '$end_with?', '$__send__', '$<<', '$last', '$pop', '$!', '$other', '$shift', '$horizontal?', '$private']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CSS'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_initialize$1, $Definition_empty$ques$2, $Definition_each$3, $Definition_gradient$4, $Definition_url$5, $Definition$6, $Definition_rgb$8, $Definition_rgba$9, $Definition$10, $Definition$12, $Definition_background$14, $Definition_border$17, $Definition_box$23, $Definition_opacity$26, $Definition_animation$27, $Definition_transition$29, $Definition_user_select$30, $Definition_transform$31, $Definition_filter$32, $Definition_method_missing$33, $Definition_style$35, $Definition_style$excl$36; self.$$prototype.style = self.$$prototype.important = nil; Opal.const_set($nesting[0], 'Style', $$$('::', 'Struct').$new("name", "value", "important")); Opal.def(self, '$initialize', $Definition_initialize$1 = function $$initialize() { var $iter = $Definition_initialize$1.$$p, block = $iter || nil, self = this; if ($iter) $Definition_initialize$1.$$p = null; if ($iter) $Definition_initialize$1.$$p = null;; self.style = []; if ($truthy(block)) { if (block.$arity()['$=='](0)) { return $send(self, 'instance_exec', [], block.$to_proc()) } else { return block.$call(self) } } else { return nil }; }, $Definition_initialize$1.$$arity = 0); Opal.def(self, '$empty?', $Definition_empty$ques$2 = function() { var self = this; return self.style['$empty?']() }, $Definition_empty$ques$2.$$arity = 0); Opal.def(self, '$each', $Definition_each$3 = function $$each() { var $iter = $Definition_each$3.$$p, block = $iter || nil, self = this; if ($iter) $Definition_each$3.$$p = null; if ($iter) $Definition_each$3.$$p = null;; return $send(self.style, 'each', [], block.$to_proc()); }, $Definition_each$3.$$arity = 0); Opal.def(self, '$gradient', $Definition_gradient$4 = function $$gradient($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send($$($nesting, 'Gradient'), 'new', Opal.to_a(args)); }, $Definition_gradient$4.$$arity = -1); Opal.def(self, '$url', $Definition_url$5 = function $$url(value) { var self = this; return "" + "url(" + (value.$to_s().$inspect()) + ")" }, $Definition_url$5.$$arity = 1); $send(["url", "blur", "brightness", "rotate", "contrast", "grayscale", "invert", "opacity", "saturate", "sepia"], 'each', [], ($Definition$6 = function(name){var self = $Definition$6.$$s || this, $$7; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$7 = function(value){var self = $$7.$$s || this; if (value == null) { value = nil; }; return "" + (name) + "(" + (value) + ")";}, $$7.$$s = self, $$7.$$arity = 1, $$7));}, $Definition$6.$$s = self, $Definition$6.$$arity = 1, $Definition$6)); Opal.def(self, '$rgb', $Definition_rgb$8 = function $$rgb(r, g, b) { var self = this; return "" + "rgb(" + (r) + ", " + (g) + ", " + (b) + ", " + (self.$a()) + ")" }, $Definition_rgb$8.$$arity = 3); Opal.def(self, '$rgba', $Definition_rgba$9 = function $$rgba(r, g, b, a) { var self = this; return "" + "rgba(" + (r) + ", " + (g) + ", " + (b) + ", " + (a) + ")" }, $Definition_rgba$9.$$arity = 4); $send(["scale", "skew", "translate"], 'each', [], ($Definition$10 = function(name){var self = $Definition$10.$$s || this, $$11; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$11 = function(a, b){var self = $$11.$$s || this; if (a == null) { a = nil; }; if (b == null) { b = nil; }; if ($truthy(b)) { return "" + (name) + "(" + (a) + ", " + (b) + ")" } else { return "" + (name) + "(" + (a) + ")" };}, $$11.$$s = self, $$11.$$arity = -2, $$11));}, $Definition$10.$$s = self, $Definition$10.$$arity = 1, $Definition$10)); $send(["translateX", "translateY", "translateZ", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"], 'each', [], ($Definition$12 = function(name){var self = $Definition$12.$$s || this, $$13; if (name == null) { name = nil; }; return $send(self, 'define_method', [name], ($$13 = function(value){var self = $$13.$$s || this; if (value == null) { value = nil; }; return "" + (name) + "(" + (value) + ")";}, $$13.$$s = self, $$13.$$arity = 1, $$13));}, $Definition$12.$$s = self, $Definition$12.$$arity = 1, $Definition$12)); Opal.def(self, '$background', $Definition_background$14 = function $$background($a) { var $post_args, args, $$15, $$16, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($$($nesting, 'Gradient')['$==='](args.$first()))) { if ($truthy($rb_gt(args.$length(), 1))) { self.$raise($$($nesting, 'NotImplementedError'), "multiple gradients not implemented yet")}; return $send(args.$first(), 'each', [], ($$15 = function(s){var self = $$15.$$s || this, $b; if (s == null) { s = nil; }; return self.$style(($truthy($b = s.$name()) ? $b : "background-image"), s.$value());}, $$15.$$s = self, $$15.$$arity = 1, $$15)); } else if ($truthy($$$('::', 'Hash')['$==='](args.$first()))) { return $send(args.$first(), 'each', [], ($$16 = function(sub, value){var self = $$16.$$s || this; if (sub == null) { sub = nil; }; if (value == null) { value = nil; }; return self.$style("" + "background-" + (sub), value);}, $$16.$$s = self, $$16.$$arity = 2, $$16)) } else { return self.$style("background", args) }; }, $Definition_background$14.$$arity = -1); Opal.def(self, '$border', $Definition_border$17 = function $$border($a) { var $post_args, args, $$18, self = this, options = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($$$('::', 'Hash')['$==='](args.$first()))) { if (args.$length()['$=='](1)) { options = args.$first()}; return $send(options, 'each', [], ($$18 = function(name, value){var self = $$18.$$s || this, $$19, $$20, $$22, $case = nil; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return (function() {$case = name; if ("top"['$===']($case) || "bottom"['$===']($case) || "left"['$===']($case) || "right"['$===']($case)) {if ($truthy($$$('::', 'Hash')['$==='](value))) { return $send(value, 'each', [], ($$19 = function(n, v){var self = $$19.$$s || this; if (n == null) { n = nil; }; if (v == null) { v = nil; }; return self.$style("" + "border-" + (name) + "-" + (n), v);}, $$19.$$s = self, $$19.$$arity = 2, $$19)) } else { return self.$style("" + "border-" + (name), value) }} else if ("radius"['$===']($case)) {if ($truthy($$$('::', 'Hash')['$==='](value))) { return $send(value, 'each', [], ($$20 = function(horizontal, value){var self = $$20.$$s || this, $$21; if (horizontal == null) { horizontal = nil; }; if (value == null) { value = nil; }; return $send(value, 'each', [], ($$21 = function(vertical, value){var self = $$21.$$s || this; if (vertical == null) { vertical = nil; }; if (value == null) { value = nil; }; self.$style("" + "-moz-border-radius-" + (horizontal) + (vertical), value); self.$style("" + "-webkit-border-" + (horizontal) + "-" + (vertical) + "-radius", value); return self.$style("" + "border-" + (horizontal) + "-" + (vertical) + "-radius", value);}, $$21.$$s = self, $$21.$$arity = 2, $$21));}, $$20.$$s = self, $$20.$$arity = 2, $$20)) } else { self.$style("-moz-border-radius", value); self.$style("-webkit-border-radius", value); return self.$style("border-radius", value); }} else if ("color"['$===']($case)) {if ($truthy($$$('::', 'Hash')['$==='](value))) { return $send(value, 'each', [], ($$22 = function(name, value){var self = $$22.$$s || this; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return self.$style("" + "border-" + (name) + "-color", value);}, $$22.$$s = self, $$22.$$arity = 2, $$22)) } else { return self.$style("border-color", value) }} else {return self.$style("" + "border-" + (name), value)}})();}, $$18.$$s = self, $$18.$$arity = 2, $$18)); } else { return self.$style("border", args) }; }, $Definition_border$17.$$arity = -1); Opal.def(self, '$box', $Definition_box$23 = function $$box(options) { var $$24, self = this; if ($truthy($$$('::', 'Hash')['$==='](options))) { return $send(options, 'each', [], ($$24 = function(name, value){var self = $$24.$$s || this, $$25, $case = nil; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return (function() {$case = name; if ("shadow"['$===']($case)) { if ($truthy($$$('::', 'Array')['$==='](value))) { if ($truthy($$$('::', 'Array')['$==='](value['$[]'](0)))) { value = $send(value, 'map', [], ($$25 = function(v){var self = $$25.$$s || this; if (v == null) { v = nil; }; return v.$join(" ");}, $$25.$$s = self, $$25.$$arity = 1, $$25)).$join(", ") } else { value = value.$join(" ") }}; self.$style("-moz-box-shadow", value); self.$style("-webkit-box-shadow", value); return self.$style("box-shadow", value);} else {return self.$style("" + "box-" + (name), value)}})();}, $$24.$$s = self, $$24.$$arity = 2, $$24)) } else { return self.$style("box", options) } }, $Definition_box$23.$$arity = 1); Opal.def(self, '$opacity', $Definition_opacity$26 = function $$opacity(value) { var self = this; self.$style("opacity", value); self.$style("-moz-opacity", value); self.$style("-ms-filter", "" + "\"progid:DXImageTransform.Microsoft.Alpha(Opacity=" + ($rb_times(value, 100).$to_i()) + ")\""); return self.$style("filter", "" + "alpha(opacity=" + ($rb_times(value, 100).$to_i()) + ")"); }, $Definition_opacity$26.$$arity = 1); Opal.def(self, '$animation', $Definition_animation$27 = function $$animation($a) { var $post_args, args, $$28, self = this, options = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($$($nesting, 'Hash')['$==='](args.$first()))) { if (args.$length()['$=='](1)) { options = args.$first()}; return $send(options, 'each', [], ($$28 = function(name, value){var self = $$28.$$s || this; if (name == null) { name = nil; }; if (value == null) { value = nil; }; self.$style("" + "-webkit-animation-" + (name), value); return self.$style("" + "animation-" + (name), value);}, $$28.$$s = self, $$28.$$arity = 2, $$28)); } else { self.$style("animation", args); return self.$style("-webkit-animation", args); }; }, $Definition_animation$27.$$arity = -1); Opal.def(self, '$transition', $Definition_transition$29 = function $$transition($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; self.$style("transition", args); self.$style("-webkit-transition", args); return self.$style("-moz-transition", args); }, $Definition_transition$29.$$arity = -1); Opal.def(self, '$user_select', $Definition_user_select$30 = function $$user_select($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; self.$style("user-select", args); self.$style("-webkit-user-select", args); self.$style("-moz-user-select", args); return self.$style("-ms-user-select", args); }, $Definition_user_select$30.$$arity = -1); Opal.def(self, '$transform', $Definition_transform$31 = function $$transform($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; self.$style("transform", args); self.$style("-webkit-transform", args); self.$style("-moz-transform", args); self.$style("-ms-transform", args); return self.$style("-o-transform", args); }, $Definition_transform$31.$$arity = -1); Opal.def(self, '$filter', $Definition_filter$32 = function $$filter($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; self.$style("filter", args); self.$style("-webkit-filter", args); self.$style("-moz-filter", args); self.$style("-ms-filter", args); return self.$style("-o-filter", args); }, $Definition_filter$32.$$arity = -1); Opal.def(self, '$method_missing', $Definition_method_missing$33 = function $$method_missing(name, $a) { var $iter = $Definition_method_missing$33.$$p, block = $iter || nil, $post_args, args, $$34, self = this, argument = nil; if ($iter) $Definition_method_missing$33.$$p = null; if ($iter) $Definition_method_missing$33.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; name = name.$to_s(); if ($truthy(name['$end_with?']("!"))) { name = name['$[]']($range(0, -2, false)); self.important = true; $send(self, '__send__', [name].concat(Opal.to_a(args)), block.$to_proc()); self.important = false; return nil;}; if (args.$length()['$=='](1)) { argument = args.$first(); if ($truthy($$$('::', 'Hash')['$==='](argument))) { $send(argument, 'each', [], ($$34 = function(sub, value){var self = $$34.$$s || this; if (sub == null) { sub = nil; }; if (value == null) { value = nil; }; return self.$style("" + (name) + "-" + (sub), value);}, $$34.$$s = self, $$34.$$arity = 2, $$34)) } else { self.$style(name, argument) }; } else { self.$style(name, args.$join(" ")) }; self.important = false; return self; }, $Definition_method_missing$33.$$arity = -2); Opal.def(self, '$style', $Definition_style$35 = function $$style(name, value, important) { var self = this; if (value == null) { value = nil; }; if (important == null) { important = self.important; }; if ($truthy($$$('::', 'Array')['$==='](value))) { value = value.$join(" ")}; if ($truthy($$($nesting, 'Style')['$==='](name))) { return self.style['$<<'](name) } else { return self.style['$<<']($$($nesting, 'Style').$new(name, value, important)) }; }, $Definition_style$35.$$arity = -2); Opal.def(self, '$style!', $Definition_style$excl$36 = function(name, value) { var self = this; if (value == null) { value = nil; }; return self.$style(name, value, true); }, $Definition_style$excl$36.$$arity = -2); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Gradient'); var $nesting = [self].concat($parent_nesting), $Gradient_initialize$37, $Gradient_each$38, $Gradient_horizontal$ques$39, $Gradient_vertical$ques$40, $Gradient_other$41, $Gradient_style$42; self.$$prototype.to = self.$$prototype.from = self.$$prototype.start = self.$$prototype.end = nil; Opal.def(self, '$initialize', $Gradient_initialize$37 = function $$initialize($a) { var $post_args, args, $b, self = this, options = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; options = (function() {if ($truthy($$$('::', 'Hash')['$==='](args.$last()))) { return args.$pop() } else { return $hash2([], {}) }; return nil; })(); self.to = options['$[]']("to"); self.from = options['$[]']("from"); if ($truthy(($truthy($b = self.to) ? self.from['$!']() : $b))) { self.from = self.$other(self.to) } else if ($truthy(($truthy($b = self.from) ? self.to['$!']() : $b))) { self.to = self.$other(self.from)}; self.start = args.$shift(); return (self.end = args.$shift()); }, $Gradient_initialize$37.$$arity = -1); Opal.def(self, '$each', $Gradient_each$38 = function $$each() { var $iter = $Gradient_each$38.$$p, block = $iter || nil, self = this; if ($iter) $Gradient_each$38.$$p = null; if ($iter) $Gradient_each$38.$$p = null;; block.$call(self.$style("" + "-moz-linear-gradient(" + (self.to) + ", " + (self.start) + " 0%, " + (self.end) + " 100%)")); if ($truthy(self['$horizontal?']())) { block.$call(self.$style("" + "-webkit-gradient(linear, " + (self.from) + " top, " + (self.to) + " top, color-stop(0%, " + (self.start) + "), color-stop(100%, " + (self.end) + "))")) } else { block.$call(self.$style("" + "-webkit-gradient(linear, left " + (self.from) + ", left " + (self.to) + ", color-stop(0%, " + (self.start) + "), color-stop(100%, " + (self.end) + "))")) }; block.$call(self.$style("" + "-webkit-linear-gradient(" + (self.to) + ", " + (self.start) + " 0%, " + (self.end) + " 100%)")); block.$call(self.$style("" + "-o-linear-gradient(" + (self.to) + ", " + (self.start) + " 0%, " + (self.end) + " 100%)")); block.$call(self.$style("" + "-ms-linear-gradient(" + (self.to) + ", " + (self.start) + " 0%, " + (self.end) + " 100%)")); return block.$call(self.$style("" + "linear-gradient(to " + (self.to) + ", " + (self.start) + " 0%, " + (self.end) + " 100%)")); }, $Gradient_each$38.$$arity = 0); Opal.def(self, '$horizontal?', $Gradient_horizontal$ques$39 = function() { var $a, self = this; return ($truthy($a = self.to['$==']("left")) ? $a : self.to['$==']("right")) }, $Gradient_horizontal$ques$39.$$arity = 0); Opal.def(self, '$vertical?', $Gradient_vertical$ques$40 = function() { var $a, self = this; return ($truthy($a = self.to['$==']("top")) ? $a : self.to['$==']("bottom")) }, $Gradient_vertical$ques$40.$$arity = 0); self.$private(); Opal.def(self, '$other', $Gradient_other$41 = function $$other(side) { var self = this, $case = nil; return (function() {$case = side; if ("left"['$===']($case)) {return "right"} else if ("right"['$===']($case)) {return "left"} else if ("top"['$===']($case)) {return "bottom"} else if ("bottom"['$===']($case)) {return "top"} else { return nil }})() }, $Gradient_other$41.$$arity = 1); return (Opal.def(self, '$style', $Gradient_style$42 = function $$style($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if (args.$length()['$=='](1)) { return $$($nesting, 'Style').$new(nil, args.$first()) } else { return $send($$($nesting, 'Style'), 'new', Opal.to_a(args)) }; }, $Gradient_style$42.$$arity = -1), nil) && 'style'; })($nesting[0], null, $nesting); })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/css/rule"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$new', '$__send__', '$to_proc']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CSS'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Rule'); var $nesting = [self].concat($parent_nesting), $Rule_initialize$1, $Rule_method_missing$2; self.$$prototype.definition = nil; self.$attr_reader("selector", "media"); Opal.def(self, '$initialize', $Rule_initialize$1 = function $$initialize(selector, media) { var self = this; self.selector = selector; self.media = media; return (self.definition = $$($nesting, 'Definition').$new()); }, $Rule_initialize$1.$$arity = 2); return (Opal.def(self, '$method_missing', $Rule_method_missing$2 = function $$method_missing($a) { var $iter = $Rule_method_missing$2.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Rule_method_missing$2.$$p = null; if ($iter) $Rule_method_missing$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.definition, '__send__', Opal.to_a(args), block.$to_proc()); }, $Rule_method_missing$2.$$arity = -1), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/css/font"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$new', '$font', '$__send__', '$to_proc']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CSS'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Font'); var $nesting = [self].concat($parent_nesting), $Font_initialize$1, $Font_method_missing$2; self.$$prototype.definition = nil; self.$attr_reader("name"); Opal.def(self, '$initialize', $Font_initialize$1 = function $$initialize(name) { var self = this; self.name = name; self.definition = $$($nesting, 'Definition').$new(); return self.$font($hash2(["family"], {"family": name})); }, $Font_initialize$1.$$arity = 1); return (Opal.def(self, '$method_missing', $Font_method_missing$2 = function $$method_missing($a) { var $iter = $Font_method_missing$2.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Font_method_missing$2.$$p = null; if ($iter) $Font_method_missing$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.definition, '__send__', Opal.to_a(args), block.$to_proc()); }, $Font_method_missing$2.$$arity = -1), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/css/animation"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$new', '$__send__', '$to_proc', '$<<', '$call', '$%', '$last']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CSS'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Animation'); var $nesting = [self].concat($parent_nesting), $Animation_initialize$3, $Animation_step$4, $Animation_from$5, $Animation_to$6, $Animation_method_missing$7; self.$$prototype.steps = nil; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Step'); var $nesting = [self].concat($parent_nesting), $Step_initialize$1, $Step_method_missing$2; self.$$prototype.definition = nil; self.$attr_reader("value"); Opal.def(self, '$initialize', $Step_initialize$1 = function $$initialize(value) { var self = this; self.value = value; return (self.definition = $$($nesting, 'Definition').$new()); }, $Step_initialize$1.$$arity = 1); return (Opal.def(self, '$method_missing', $Step_method_missing$2 = function $$method_missing($a) { var $iter = $Step_method_missing$2.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Step_method_missing$2.$$p = null; if ($iter) $Step_method_missing$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.definition, '__send__', Opal.to_a(args), block.$to_proc()); }, $Step_method_missing$2.$$arity = -1), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting); self.$attr_reader("name", "steps"); Opal.def(self, '$initialize', $Animation_initialize$3 = function $$initialize(name) { var self = this; self.name = name; return (self.steps = []); }, $Animation_initialize$3.$$arity = 1); Opal.def(self, '$step', $Animation_step$4 = function $$step(value) { var $iter = $Animation_step$4.$$p, block = $iter || nil, self = this; if ($iter) $Animation_step$4.$$p = null; if ($iter) $Animation_step$4.$$p = null;; self.steps['$<<']($$($nesting, 'Step').$new(value)); return block.$call(); }, $Animation_step$4.$$arity = 1); Opal.def(self, '$from', $Animation_from$5 = function $$from(value) { var $iter = $Animation_from$5.$$p, block = $iter || nil, self = this; if ($iter) $Animation_from$5.$$p = null; if ($iter) $Animation_from$5.$$p = null;; self.steps['$<<']($$($nesting, 'Step').$new((0)['$%']())); return block.$call(); }, $Animation_from$5.$$arity = 1); Opal.def(self, '$to', $Animation_to$6 = function $$to(value) { var $iter = $Animation_to$6.$$p, block = $iter || nil, self = this; if ($iter) $Animation_to$6.$$p = null; if ($iter) $Animation_to$6.$$p = null;; self.steps['$<<']($$($nesting, 'Step').$new((100)['$%']())); return block.$call(); }, $Animation_to$6.$$arity = 1); return (Opal.def(self, '$method_missing', $Animation_method_missing$7 = function $$method_missing($a) { var $iter = $Animation_method_missing$7.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Animation_method_missing$7.$$p = null; if ($iter) $Animation_method_missing$7.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.steps.$last(), '__send__', Opal.to_a(args), block.$to_proc()); }, $Animation_method_missing$7.$$arity = -1), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], $$($nesting, 'BasicObject'), $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/css"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $range = Opal.range; Opal.add_stubs(['$require', '$each', '$start_with?', '$+', '$[]', '$==', '$attr_reader', '$raise', '$arity', '$instance_exec', '$to_proc', '$call', '$any?', '$include?', '$<<', '$new', '$selector', '$pop', '$method_missing', '$__send__', '$last']); self.$require("paggio/css/unit"); self.$require("paggio/css/color"); self.$require("paggio/css/definition"); self.$require("paggio/css/rule"); self.$require("paggio/css/font"); self.$require("paggio/css/animation"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CSS'); var $nesting = [self].concat($parent_nesting), $CSS_selector$1, $CSS_initialize$3, $CSS_rule$4, $CSS_media$7, $CSS_font$8, $CSS_animation$9, $CSS_method_missing$10; self.$$prototype.media = self.$$prototype.current = self.$$prototype.fonts = self.$$prototype.animations = nil; Opal.defs(self, '$selector', $CSS_selector$1 = function $$selector(list) { var $$2, self = this, result = nil; result = ""; $send(list, 'each', [], ($$2 = function(part){var self = $$2.$$s || this; if (part == null) { part = nil; }; if ($truthy(part['$start_with?']("&"))) { return (result = $rb_plus(result, part['$[]']($range(1, -1, false)))) } else { return (result = $rb_plus(result, $rb_plus(" ", part))) };}, $$2.$$s = self, $$2.$$arity = 1, $$2)); if (result['$[]'](0)['$=='](" ")) { return result['$[]']($range(1, -1, false)) } else { return result }; }, $CSS_selector$1.$$arity = 1); self.$attr_reader("rules", "media", "fonts", "animations"); Opal.def(self, '$initialize', $CSS_initialize$3 = function $$initialize() { var $iter = $CSS_initialize$3.$$p, block = $iter || nil, self = this; if ($iter) $CSS_initialize$3.$$p = null; if ($iter) $CSS_initialize$3.$$p = null;; if ($truthy(block)) { } else { $$$('::', 'Kernel').$raise($$$('::', 'ArgumentError'), "no block given") }; self.selector = []; self.current = []; self.rules = []; self.fonts = []; self.animations = []; if (block.$arity()['$=='](0)) { return $send(self, 'instance_exec', [], block.$to_proc()) } else { return block.$call(self) }; }, $CSS_initialize$3.$$arity = 0); Opal.def(self, '$rule', $CSS_rule$4 = function $$rule($a) { var $iter = $CSS_rule$4.$$p, block = $iter || nil, $post_args, names, $$5, $$6, self = this; if ($iter) $CSS_rule$4.$$p = null; if ($iter) $CSS_rule$4.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; if ($truthy(block)) { } else { return nil }; if ($truthy($send(names, 'any?', [], ($$5 = function(n){var self = $$5.$$s || this; if (n == null) { n = nil; }; return n['$include?'](",");}, $$5.$$s = self, $$5.$$arity = 1, $$5)))) { $$$('::', 'Kernel').$raise($$$('::', 'ArgumentError'), "selectors cannot contain commas")}; return $send(names, 'each', [], ($$6 = function(name){var self = $$6.$$s || this; if (self.selector == null) self.selector = nil; if (self.current == null) self.current = nil; if (self.media == null) self.media = nil; if (self.rules == null) self.rules = nil; if (name == null) { name = nil; }; self.selector['$<<'](name); self.current['$<<']($$($nesting, 'Rule').$new($$($nesting, 'CSS').$selector(self.selector), self.media)); block.$call(); self.selector.$pop(); return self.rules['$<<'](self.current.$pop());}, $$6.$$s = self, $$6.$$arity = 1, $$6)); }, $CSS_rule$4.$$arity = -1); Opal.def(self, '$media', $CSS_media$7 = function $$media(query, $a) { var $iter = $CSS_media$7.$$p, block = $iter || nil, $post_args, args, $b, self = this, old = nil; if ($iter) $CSS_media$7.$$p = null; if ($iter) $CSS_media$7.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(block)) { $b = [self.media, query], (old = $b[0]), (self.media = $b[1]), $b; block.$call(); return (self.media = old); } else { return $send(self, 'method_missing', ["media", query].concat(Opal.to_a(args))) }; }, $CSS_media$7.$$arity = -2); Opal.def(self, '$font', $CSS_font$8 = function $$font(name, $a) { var $iter = $CSS_font$8.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $CSS_font$8.$$p = null; if ($iter) $CSS_font$8.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(block)) { self.current['$<<']($$($nesting, 'Font').$new(name)); block.$call(); return self.fonts['$<<'](self.current.$pop()); } else { return $send(self, 'method_missing', ["font", name].concat(Opal.to_a(args))) }; }, $CSS_font$8.$$arity = -2); Opal.def(self, '$animation', $CSS_animation$9 = function $$animation(name, $a) { var $iter = $CSS_animation$9.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $CSS_animation$9.$$p = null; if ($iter) $CSS_animation$9.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(block)) { self.current['$<<']($$($nesting, 'Animation').$new(name)); block.$call(); return self.animations['$<<'](self.current.$pop()); } else { return $send(self, 'method_missing', ["animation", name].concat(Opal.to_a(args))) }; }, $CSS_animation$9.$$arity = -2); return (Opal.def(self, '$method_missing', $CSS_method_missing$10 = function $$method_missing($a) { var $iter = $CSS_method_missing$10.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $CSS_method_missing$10.$$p = null; if ($iter) $CSS_method_missing$10.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.current.$last(), '__send__', Opal.to_a(args), block.$to_proc()); }, $CSS_method_missing$10.$$arity = -1), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'BasicObject'), $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HTML'); var $nesting = [self].concat($parent_nesting), $HTML_style$11; self.$$prototype.current = self.$$prototype.roots = nil; return (Opal.def(self, '$style', $HTML_style$11 = function $$style() { var $iter = $HTML_style$11.$$p, block = $iter || nil, $a, self = this; if ($iter) $HTML_style$11.$$p = null; if ($iter) $HTML_style$11.$$p = null;; return ($truthy($a = self.current) ? $a : self.roots)['$<<']($send($$($nesting, 'CSS'), 'new', [], block.$to_proc())); }, $HTML_style$11.$$arity = 0), nil) && 'style' })($nesting[0], $$($nesting, 'BasicObject'), $nesting); })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["stringio"] = function(Opal) { function $rb_ge(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs >= rhs : lhs['$>='](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $gvars = Opal.gvars; Opal.add_stubs(['$include', '$new', '$call', '$close', '$attr_accessor', '$length', '$include?', '$!', '$check_readable', '$==', '$===', '$>=', '$raise', '$>', '$+', '$-', '$seek', '$enum_for', '$eof?', '$ord', '$[]', '$to_str', '$chomp', '$check_writable', '$String', '$write', '$closed_write?', '$closed_read?']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'StringIO'); var $nesting = [self].concat($parent_nesting), $StringIO_open$1, $StringIO_initialize$2, $StringIO_eof$ques$3, $StringIO_seek$4, $StringIO_tell$5, $StringIO_rewind$6, $StringIO_each_byte$7, $StringIO_each_char$8, $StringIO_each$9, $StringIO_write$10, $StringIO_read$11, $StringIO_close$12, $StringIO_close_read$13, $StringIO_close_write$14, $StringIO_closed$ques$15, $StringIO_closed_read$ques$16, $StringIO_closed_write$ques$17, $StringIO_check_writable$18, $StringIO_check_readable$19; self.$$prototype.position = self.$$prototype.string = self.$$prototype.closed = nil; self.$include($$$($$($nesting, 'IO'), 'Readable')); self.$include($$$($$($nesting, 'IO'), 'Writable')); Opal.defs(self, '$open', $StringIO_open$1 = function $$open(string, mode) { var $iter = $StringIO_open$1.$$p, block = $iter || nil, self = this, io = nil, res = nil; if ($iter) $StringIO_open$1.$$p = null; if ($iter) $StringIO_open$1.$$p = null;; if (string == null) { string = ""; }; if (mode == null) { mode = nil; }; io = self.$new(string, mode); res = block.$call(io); io.$close(); return res; }, $StringIO_open$1.$$arity = -1); self.$attr_accessor("string"); Opal.def(self, '$initialize', $StringIO_initialize$2 = function $$initialize(string, mode) { var $a, self = this; if (string == null) { string = ""; }; if (mode == null) { mode = "rw"; }; self.string = string; self.position = string.$length(); if ($truthy(($truthy($a = mode['$include?']("r")) ? mode['$include?']("w")['$!']() : $a))) { return (self.closed = "write") } else if ($truthy(($truthy($a = mode['$include?']("w")) ? mode['$include?']("r")['$!']() : $a))) { return (self.closed = "read") } else { return nil }; }, $StringIO_initialize$2.$$arity = -1); Opal.def(self, '$eof?', $StringIO_eof$ques$3 = function() { var self = this; self.$check_readable(); return self.position['$=='](self.string.$length()); }, $StringIO_eof$ques$3.$$arity = 0); Opal.alias(self, "eof", "eof?"); Opal.def(self, '$seek', $StringIO_seek$4 = function $$seek(pos, whence) { var self = this, $case = nil; if (whence == null) { whence = $$$($$($nesting, 'IO'), 'SEEK_SET'); }; $case = whence; if ($$$($$($nesting, 'IO'), 'SEEK_SET')['$===']($case)) { if ($truthy($rb_ge(pos, 0))) { } else { self.$raise($$$($$($nesting, 'Errno'), 'EINVAL')) }; self.position = pos;} else if ($$$($$($nesting, 'IO'), 'SEEK_CUR')['$===']($case)) {if ($truthy($rb_gt($rb_plus(self.position, pos), self.string.$length()))) { self.position = self.string.$length() } else { self.position = $rb_plus(self.position, pos) }} else if ($$$($$($nesting, 'IO'), 'SEEK_END')['$===']($case)) {if ($truthy($rb_gt(pos, self.string.$length()))) { self.position = 0 } else { self.position = $rb_minus(self.position, pos) }}; return 0; }, $StringIO_seek$4.$$arity = -2); Opal.def(self, '$tell', $StringIO_tell$5 = function $$tell() { var self = this; return self.position }, $StringIO_tell$5.$$arity = 0); Opal.alias(self, "pos", "tell"); Opal.alias(self, "pos=", "seek"); Opal.def(self, '$rewind', $StringIO_rewind$6 = function $$rewind() { var self = this; return self.$seek(0) }, $StringIO_rewind$6.$$arity = 0); Opal.def(self, '$each_byte', $StringIO_each_byte$7 = function $$each_byte() { var $iter = $StringIO_each_byte$7.$$p, block = $iter || nil, $a, self = this, i = nil; if ($iter) $StringIO_each_byte$7.$$p = null; if ($iter) $StringIO_each_byte$7.$$p = null;; if ($truthy(block)) { } else { return self.$enum_for("each_byte") }; self.$check_readable(); i = self.position; while (!($truthy(self['$eof?']()))) { block.$call(self.string['$[]'](i).$ord()); i = $rb_plus(i, 1); }; return self; }, $StringIO_each_byte$7.$$arity = 0); Opal.def(self, '$each_char', $StringIO_each_char$8 = function $$each_char() { var $iter = $StringIO_each_char$8.$$p, block = $iter || nil, $a, self = this, i = nil; if ($iter) $StringIO_each_char$8.$$p = null; if ($iter) $StringIO_each_char$8.$$p = null;; if ($truthy(block)) { } else { return self.$enum_for("each_char") }; self.$check_readable(); i = self.position; while (!($truthy(self['$eof?']()))) { block.$call(self.string['$[]'](i)); i = $rb_plus(i, 1); }; return self; }, $StringIO_each_char$8.$$arity = 0); Opal.def(self, '$each', $StringIO_each$9 = function $$each(separator) { var $iter = $StringIO_each$9.$$p, $yield = $iter || nil, self = this, chomp_lines = nil; if ($gvars["/"] == null) $gvars["/"] = nil; if ($iter) $StringIO_each$9.$$p = null; if (separator == null) { separator = $gvars["/"]; }; if (($yield !== nil)) { } else { return self.$enum_for("each_line") }; self.$check_readable(); chomp_lines = false; if ($truthy($$$('::', 'Hash')['$==='](separator))) { separator = (function() {if ($truthy((chomp_lines = separator['$[]']("chomp")))) { return /\r?\n/ } else { return $gvars["/"] }; return nil; })() } else if ($truthy(separator)) { separator = separator.$to_str() } else { separator = undefined }; var str = self.string, stringLength = str.length; if (self.position < stringLength) str = str.substr(self.position); if (separator) { var chomped = (str).$chomp(), trailing = str.length !== chomped.length, splitted = chomped.split(separator); for (var i = 0, len = splitted.length; i < len; i++) { var line = chomp_lines ? splitted[i] : (i < len - 1 || trailing ? splitted[i] + separator : splitted[i]); Opal.yield1($yield, line); } } else if (separator === undefined) { Opal.yield1($yield, str); } else { var m, re = /(.+(?:\n\n|$))\n*/g; while ((m = re.exec(str))) Opal.yield1($yield, m[1]); } self.position = stringLength; ; return self; }, $StringIO_each$9.$$arity = -1); Opal.alias(self, "each_line", "each"); Opal.def(self, '$write', $StringIO_write$10 = function $$write(string) { var self = this, before = nil, after = nil; self.$check_writable(); string = self.$String(string); if (self.string.$length()['$=='](self.position)) { self.string = $rb_plus(self.string, string); return (self.position = $rb_plus(self.position, string.$length())); } else { before = self.string['$[]'](Opal.Range.$new(0, $rb_minus(self.position, 1), false)); after = self.string['$[]'](Opal.Range.$new($rb_plus(self.position, string.$length()), -1, false)); self.string = $rb_plus($rb_plus(before, string), after); return (self.position = $rb_plus(self.position, string.$length())); }; }, $StringIO_write$10.$$arity = 1); Opal.def(self, '$read', $StringIO_read$11 = function $$read(length, outbuf) { var self = this, string = nil, str = nil; if (length == null) { length = nil; }; if (outbuf == null) { outbuf = nil; }; self.$check_readable(); if ($truthy(self['$eof?']())) { return nil}; string = (function() {if ($truthy(length)) { str = self.string['$[]'](self.position, length); self.position = $rb_plus(self.position, length); return str; } else { str = self.string['$[]'](Opal.Range.$new(self.position, -1, false)); self.position = self.string.$length(); return str; }; return nil; })(); if ($truthy(outbuf)) { return outbuf.$write(string) } else { return string }; }, $StringIO_read$11.$$arity = -1); Opal.def(self, '$close', $StringIO_close$12 = function $$close() { var self = this; return (self.closed = "both") }, $StringIO_close$12.$$arity = 0); Opal.def(self, '$close_read', $StringIO_close_read$13 = function $$close_read() { var self = this; if (self.closed['$==']("write")) { return (self.closed = "both") } else { return (self.closed = "read") } }, $StringIO_close_read$13.$$arity = 0); Opal.def(self, '$close_write', $StringIO_close_write$14 = function $$close_write() { var self = this; if (self.closed['$==']("read")) { return (self.closed = "both") } else { return (self.closed = "write") } }, $StringIO_close_write$14.$$arity = 0); Opal.def(self, '$closed?', $StringIO_closed$ques$15 = function() { var self = this; return self.closed['$==']("both") }, $StringIO_closed$ques$15.$$arity = 0); Opal.def(self, '$closed_read?', $StringIO_closed_read$ques$16 = function() { var $a, self = this; return ($truthy($a = self.closed['$==']("read")) ? $a : self.closed['$==']("both")) }, $StringIO_closed_read$ques$16.$$arity = 0); Opal.def(self, '$closed_write?', $StringIO_closed_write$ques$17 = function() { var $a, self = this; return ($truthy($a = self.closed['$==']("write")) ? $a : self.closed['$==']("both")) }, $StringIO_closed_write$ques$17.$$arity = 0); Opal.def(self, '$check_writable', $StringIO_check_writable$18 = function $$check_writable() { var self = this; if ($truthy(self['$closed_write?']())) { return self.$raise($$($nesting, 'IOError'), "not opened for writing") } else { return nil } }, $StringIO_check_writable$18.$$arity = 0); return (Opal.def(self, '$check_readable', $StringIO_check_readable$19 = function $$check_readable() { var self = this; if ($truthy(self['$closed_read?']())) { return self.$raise($$($nesting, 'IOError'), "not opened for reading") } else { return nil } }, $StringIO_check_readable$19.$$arity = 0), nil) && 'check_readable'; })($nesting[0], $$($nesting, 'IO'), $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio/formatter"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_times(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs * rhs : lhs['$*'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2, $send = Opal.send; Opal.add_stubs(['$require', '$[]=', '$to_h', '$-', '$[]', '$dup', '$deep_merge!', '$call', '$replace', '$===', '$new', '$merge', '$each', '$string', '$indent?', '$+', '$lines', '$puts', '$*', '$chomp', '$print', '$gsub', '$to_s', '$for', '$version', '$indent', '$format', '$instance_eval', '$empty?', '$map', '$escape', '$<<', '$join', '$include?', '$downcase', '$name', '$value', '$important', '$fonts', '$animations', '$steps', '$reverse', '$rules', '$media', '$selector', '$deindent']); self.$require("stringio"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting), $Paggio$14, $Paggio$17, $Paggio$24, $Paggio$25; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Formatter'); var $nesting = [self].concat($parent_nesting), $Formatter_to_h$1, $Formatter_for$2, $Formatter_options$3, $Formatter_initialize$4, $Formatter_format$5, $Formatter_to_s$7, $Formatter_indent$ques$8, $Formatter_indent$9, $Formatter_deindent$10, $Formatter_print$11, $Formatter_escape$13; self.$$prototype.options = self.$$prototype.io = nil; Opal.defs(self, '$to_h', $Formatter_to_h$1 = function $$to_h() { var $a, self = this; if (self.formatters == null) self.formatters = nil; return (self.formatters = ($truthy($a = self.formatters) ? $a : $hash2([], {}))) }, $Formatter_to_h$1.$$arity = 0); Opal.defs(self, '$for', $Formatter_for$2 = function(klass) { var $iter = $Formatter_for$2.$$p, block = $iter || nil, self = this, $writer = nil; if ($iter) $Formatter_for$2.$$p = null; if ($iter) $Formatter_for$2.$$p = null;; if ($truthy(block)) { $writer = [klass, block]; $send(self.$to_h(), '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; } else { return self.$to_h()['$[]'](klass) }; }, $Formatter_for$2.$$arity = 1); Opal.defs(self, '$options', $Formatter_options$3 = function $$options(options) { var $iter = $Formatter_options$3.$$p, block = $iter || nil, self = this, old = nil, result = nil; if ($iter) $Formatter_options$3.$$p = null; if ($iter) $Formatter_options$3.$$p = null;; old = $$($nesting, 'OPTIONS').$dup(); $$($nesting, 'Utils')['$deep_merge!']($$($nesting, 'OPTIONS'), options); result = block.$call(); $$($nesting, 'OPTIONS').$replace(old); return result; }, $Formatter_options$3.$$arity = 1); Opal.const_set($nesting[0], 'OPTIONS', $hash2(["indent"], {"indent": $hash2(["level", "with"], {"level": 0, "with": "\t"})})); Opal.def(self, '$initialize', $Formatter_initialize$4 = function $$initialize(io, options) { var $a, self = this; if (io == null) { io = nil; }; if (options == null) { options = $hash2([], {}); }; if ($truthy($$($nesting, 'Hash')['$==='](io))) { self.io = $$($nesting, 'StringIO').$new(); self.options = io; } else { self.io = ($truthy($a = io) ? $a : $$($nesting, 'StringIO').$new()); self.options = options; }; return (self.options = $$($nesting, 'OPTIONS').$merge(self.options)); }, $Formatter_initialize$4.$$arity = -1); Opal.def(self, '$format', $Formatter_format$5 = function $$format(item) { var $$6, self = this; (function(){var $brk = Opal.new_brk(); try {return $send($$($nesting, 'Formatter').$to_h(), 'each', [], ($$6 = function(klass, block){var self = $$6.$$s || this; if (klass == null) { klass = nil; }; if (block == null) { block = nil; }; if ($truthy(klass['$==='](item))) { block.$call(self, item); Opal.brk(nil, $brk); } else { return nil };}, $$6.$$s = self, $$6.$$brk = $brk, $$6.$$arity = 2, $$6)) } catch (err) { if (err === $brk) { return err.$v } else { throw err } }})(); return self; }, $Formatter_format$5.$$arity = 1); Opal.def(self, '$to_s', $Formatter_to_s$7 = function $$to_s() { var self = this; return self.io.$string() }, $Formatter_to_s$7.$$arity = 0); Opal.def(self, '$indent?', $Formatter_indent$ques$8 = function() { var $iter = $Formatter_indent$ques$8.$$p, block = $iter || nil, self = this; if ($iter) $Formatter_indent$ques$8.$$p = null; if ($iter) $Formatter_indent$ques$8.$$p = null;; try { return self.options['$[]']("indent")['$[]']("level") } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return false } finally { Opal.pop_exception() } } else { throw $err; } }; }, $Formatter_indent$ques$8.$$arity = 0); Opal.def(self, '$indent', $Formatter_indent$9 = function $$indent() { var $iter = $Formatter_indent$9.$$p, block = $iter || nil, self = this, $binary_op_recvr_tmp_1 = nil, $writer = nil, $binary_op_recvr_tmp_2 = nil, $binary_op_recvr_tmp_3 = nil; if ($iter) $Formatter_indent$9.$$p = null; if ($iter) $Formatter_indent$9.$$p = null;; if ($truthy(self['$indent?']())) { if ($truthy(block)) { $binary_op_recvr_tmp_1 = self.options['$[]']("indent"); $writer = ["level", $rb_plus($binary_op_recvr_tmp_1['$[]']("level"), 1)]; $send($binary_op_recvr_tmp_1, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];;; block.$call(); $binary_op_recvr_tmp_2 = self.options['$[]']("indent"); $writer = ["level", $rb_minus($binary_op_recvr_tmp_2['$[]']("level"), 1)]; $send($binary_op_recvr_tmp_2, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];;; } else { $binary_op_recvr_tmp_3 = self.options['$[]']("indent"); $writer = ["level", $rb_plus($binary_op_recvr_tmp_3['$[]']("level"), 1)]; $send($binary_op_recvr_tmp_3, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];; } } else if ($truthy(block)) { return block.$call() } else { return nil }; }, $Formatter_indent$9.$$arity = 0); Opal.def(self, '$deindent', $Formatter_deindent$10 = function $$deindent() { var self = this, $binary_op_recvr_tmp_4 = nil, $writer = nil; if ($truthy(self['$indent?']())) { $binary_op_recvr_tmp_4 = self.options['$[]']("indent"); $writer = ["level", $rb_minus($binary_op_recvr_tmp_4['$[]']("level"), 1)]; $send($binary_op_recvr_tmp_4, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];; } else { return nil } }, $Formatter_deindent$10.$$arity = 0); Opal.def(self, '$print', $Formatter_print$11 = function $$print(text) { var $$12, self = this, level = nil; if ($truthy((level = self['$indent?']()))) { return $send(text.$lines(), 'each', [], ($$12 = function(line){var self = $$12.$$s || this; if (self.io == null) self.io = nil; if (self.options == null) self.options = nil; if (line == null) { line = nil; }; return self.io.$puts("" + ($rb_times(self.options['$[]']("indent")['$[]']("with"), level)) + (line.$chomp()));}, $$12.$$s = self, $$12.$$arity = 1, $$12)) } else { return self.io.$print(text) } }, $Formatter_print$11.$$arity = 1); return (Opal.def(self, '$escape', $Formatter_escape$13 = function $$escape(string) { var self = this; return string.$to_s().$gsub(/["><']|&(?!([a-zA-Z]+|(#\d+));)/, $hash2(["&", ">", "<", "\"", "'"], {"&": "&", ">": ">", "<": "<", "\"": """, "'": "'"})) }, $Formatter_escape$13.$$arity = 1), nil) && 'escape'; })($nesting[0], null, $nesting); $send($$($nesting, 'Formatter'), 'for', [$$($nesting, 'HTML')], ($Paggio$14 = function(f, item){var self = $Paggio$14.$$s || this, $$15, $case = nil; if (f == null) { f = nil; }; if (item == null) { item = nil; }; $case = item.$version(); if ((5)['$===']($case)) {f.$print("")}; f.$print(""); $send(f, 'indent', [], ($$15 = function(){var self = $$15.$$s || this, $$16; return $send(item, 'each', [], ($$16 = function(root){var self = $$16.$$s || this; if (root == null) { root = nil; }; return f.$format(root);}, $$16.$$s = self, $$16.$$arity = 1, $$16))}, $$15.$$s = self, $$15.$$arity = 0, $$15)); return f.$print("");}, $Paggio$14.$$s = self, $Paggio$14.$$arity = 2, $Paggio$14)); $send($$($nesting, 'Formatter'), 'for', [$$$($$($nesting, 'HTML'), 'Element')], ($Paggio$17 = function(f, item){var self = $Paggio$17.$$s || this, $a, $b, $$18, $$19, $$20, name = nil, attributes = nil, class_names = nil, attrs = nil; if (f == null) { f = nil; }; if (item == null) { item = nil; }; $b = $send(item, 'instance_eval', [], ($$18 = function(){var self = $$18.$$s || this; if (self.name == null) self.name = nil; if (self.attributes == null) self.attributes = nil; if (self.class_names == null) self.class_names = nil; return [self.name, self.attributes, self.class_names]}, $$18.$$s = self, $$18.$$arity = 0, $$18)), $a = Opal.to_ary($b), (name = ($a[0] == null ? nil : $a[0])), (attributes = ($a[1] == null ? nil : $a[1])), (class_names = ($a[2] == null ? nil : $a[2])), $b; if ($truthy(($truthy($a = attributes['$empty?']()) ? class_names['$empty?']() : $a))) { f.$print("" + "<" + (name) + ">") } else { attrs = $send(attributes, 'map', [], ($$19 = function(key, value){var self = $$19.$$s || this; if (key == null) { key = nil; }; if (value == null) { value = nil; }; return "" + (f.$escape(key)) + "=\"" + (f.$escape(value)) + "\"";}, $$19.$$s = self, $$19.$$arity = 2, $$19)); if ($truthy(class_names['$empty?']())) { } else { attrs['$<<']("" + "class=\"" + (f.$escape(class_names.$join(" "))) + "\"") }; f.$print("" + "<" + (name) + " " + (attrs.$join(" ")) + ">"); }; if ($truthy(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"]['$include?'](name.$to_s().$downcase()))) { return nil;}; $send(f, 'indent', [], ($$20 = function(){var self = $$20.$$s || this, $$21, $$22, inner = nil; if ($truthy((inner = $send(item, 'instance_eval', [], ($$21 = function(){var self = $$21.$$s || this; if (self.inner_html == null) self.inner_html = nil; return self.inner_html}, $$21.$$s = self, $$21.$$arity = 0, $$21))))) { return f.$print(inner) } else { return $send(item, 'each', [], ($$22 = function(child){var self = $$22.$$s || this, $$23, $case = nil; if (child == null) { child = nil; }; return (function() {$case = child; if ($$($nesting, 'String')['$===']($case)) {return f.$print(f.$escape(child))} else if ($$($nesting, 'CSS')['$===']($case)) { f.$print("");} else {return f.$format(child)}})();}, $$22.$$s = self, $$22.$$arity = 1, $$22)) }}, $$20.$$s = self, $$20.$$arity = 0, $$20)); return f.$print("" + "");}, $Paggio$17.$$s = self, $Paggio$17.$$arity = 2, $Paggio$17)); $send($$($nesting, 'Formatter'), 'for', [$$$($$$($$($nesting, 'CSS'), 'Definition'), 'Style')], ($Paggio$24 = function(f, style){var self = $Paggio$24.$$s || this; if (f == null) { f = nil; }; if (style == null) { style = nil; }; return f.$print("" + (style.$name()) + ": " + (style.$value()) + ((function() {if ($truthy(style.$important())) { return " !important" } else { return nil }; return nil; })()) + ";");}, $Paggio$24.$$s = self, $Paggio$24.$$arity = 2, $Paggio$24)); return $send($$($nesting, 'Formatter'), 'for', [$$($nesting, 'CSS')], ($Paggio$25 = function(f, item){var self = $Paggio$25.$$s || this, $$26, $$29, $$33; if (f == null) { f = nil; }; if (item == null) { item = nil; }; $send(item.$fonts(), 'each', [], ($$26 = function(font){var self = $$26.$$s || this, $$27; if (font == null) { font = nil; }; f.$print("@font-face {"); $send(f, 'indent', [], ($$27 = function(){var self = $$27.$$s || this, $$28; return $send(font, 'each', [], ($$28 = function(style){var self = $$28.$$s || this; if (style == null) { style = nil; }; return f.$format(style);}, $$28.$$s = self, $$28.$$arity = 1, $$28))}, $$27.$$s = self, $$27.$$arity = 0, $$27)); return f.$print("}");}, $$26.$$s = self, $$26.$$arity = 1, $$26)); $send(item.$animations(), 'each', [], ($$29 = function(animation){var self = $$29.$$s || this, $$30; if (animation == null) { animation = nil; }; return $send(["", "-webkit-", "-moz-", "-o-"], 'each', [], ($$30 = function(platform){var self = $$30.$$s || this, $$31; if (platform == null) { platform = nil; }; f.$print("" + "@" + (platform) + "keyframes " + (animation.$name()) + " {"); $send(animation.$steps(), 'each', [], ($$31 = function(step){var self = $$31.$$s || this, $$32; if (step == null) { step = nil; }; f.$print("" + (step.$value()) + " {"); $send(step, 'each', [], ($$32 = function(style){var self = $$32.$$s || this; if (style == null) { style = nil; }; return f.$format(style);}, $$32.$$s = self, $$32.$$arity = 1, $$32)); return f.$print("}");}, $$31.$$s = self, $$31.$$arity = 1, $$31)); return f.$print("}");}, $$30.$$s = self, $$30.$$arity = 1, $$30));}, $$29.$$s = self, $$29.$$arity = 1, $$29)); return $send(item.$rules().$reverse(), 'each', [], ($$33 = function(rule){var self = $$33.$$s || this, $$34, m = nil; if (rule == null) { rule = nil; }; if ($truthy(rule['$empty?']())) { return nil;}; if ($truthy((m = rule.$media()))) { f.$print("" + "@media " + (m) + " {"); f.$indent();}; f.$print("" + (rule.$selector()) + " {"); $send(f, 'indent', [], ($$34 = function(){var self = $$34.$$s || this, $$35; return $send(rule, 'each', [], ($$35 = function(style){var self = $$35.$$s || this; if (style == null) { style = nil; }; return f.$format(style);}, $$35.$$s = self, $$35.$$arity = 1, $$35))}, $$34.$$s = self, $$34.$$arity = 0, $$34)); f.$print("}"); if ($truthy(rule.$media())) { f.$print("}"); return f.$deindent(); } else { return nil };}, $$33.$$s = self, $$33.$$arity = 1, $$33));}, $Paggio$25.$$s = self, $Paggio$25.$$arity = 2, $Paggio$25)); })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["paggio"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$require', '$options', '$to_proc', '$to_s', '$format', '$new', '$tap', '$each']); self.$require("paggio/utils"); self.$require("paggio/html"); self.$require("paggio/css"); self.$require("paggio/formatter"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Paggio'); var $nesting = [self].concat($parent_nesting), $Paggio_options$1, $Paggio_indent$2, $Paggio_css$3, $Paggio_html$4, $Paggio_html$excl$5; Opal.defs(self, '$options', $Paggio_options$1 = function $$options(options) { var $iter = $Paggio_options$1.$$p, block = $iter || nil, self = this; if ($iter) $Paggio_options$1.$$p = null; if ($iter) $Paggio_options$1.$$p = null;; return $send($$($nesting, 'Formatter'), 'options', [options], block.$to_proc()); }, $Paggio_options$1.$$arity = 1); Opal.defs(self, '$indent', $Paggio_indent$2 = function $$indent(options) { var $iter = $Paggio_indent$2.$$p, block = $iter || nil, self = this; if ($iter) $Paggio_indent$2.$$p = null; if ($iter) $Paggio_indent$2.$$p = null;; return $send(self, 'options', [$hash2(["indent"], {"indent": options})], block.$to_proc()); }, $Paggio_indent$2.$$arity = 1); Opal.defs(self, '$css', $Paggio_css$3 = function $$css($a) { var $iter = $Paggio_css$3.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Paggio_css$3.$$p = null; if ($iter) $Paggio_css$3.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $$($nesting, 'Formatter').$new().$format($send($$($nesting, 'CSS'), 'new', Opal.to_a(args), block.$to_proc())).$to_s(); }, $Paggio_css$3.$$arity = -1); Opal.defs(self, '$html', $Paggio_html$4 = function $$html($a) { var $iter = $Paggio_html$4.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Paggio_html$4.$$p = null; if ($iter) $Paggio_html$4.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $$($nesting, 'Formatter').$new().$format($send($$($nesting, 'HTML'), 'new', Opal.to_a(args), block.$to_proc())).$to_s(); }, $Paggio_html$4.$$arity = -1); return (Opal.defs(self, '$html!', $Paggio_html$excl$5 = function() { var $iter = $Paggio_html$excl$5.$$p, block = $iter || nil, $$6, self = this; if ($iter) $Paggio_html$excl$5.$$p = null; if ($iter) $Paggio_html$excl$5.$$p = null;; return $send($$($nesting, 'Formatter').$new(), 'tap', [], ($$6 = function(f){var self = $$6.$$s || this, $$7; if (f == null) { f = nil; }; return $send($send($$($nesting, 'HTML'), 'new', [], block.$to_proc()), 'each', [], ($$7 = function(root){var self = $$7.$$s || this; if (root == null) { root = nil; }; return f.$format(root);}, $$7.$$s = self, $$7.$$arity = 1, $$7));}, $$6.$$s = self, $$6.$$arity = 1, $$6)).$to_s(); }, $Paggio_html$excl$5.$$arity = 0), nil) && 'html!'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/version"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module; return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); Opal.const_set($nesting[0], 'VERSION', "0.2.0") })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/utils"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$new', '$encode_uri', '$to_s', '$encode_uri_component', '$[]', '$map', '$split', '$decode_uri_component', '$join']); (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); Opal.const_set($nesting[0], 'Size', $$($nesting, 'Struct').$new("width", "height")); Opal.const_set($nesting[0], 'Position', $$($nesting, 'Struct').$new("x", "y")); })($nesting[0], $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Object'); var $nesting = [self].concat($parent_nesting), $Object_encode_uri$1, $Object_encode_uri_component$2; Opal.def(self, '$encode_uri', $Object_encode_uri$1 = function $$encode_uri() { var self = this; return self.$to_s().$encode_uri() }, $Object_encode_uri$1.$$arity = 0); return (Opal.def(self, '$encode_uri_component', $Object_encode_uri_component$2 = function $$encode_uri_component() { var self = this; return self.$to_s().$encode_uri_component() }, $Object_encode_uri_component$2.$$arity = 0), nil) && 'encode_uri_component'; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'String'); var $nesting = [self].concat($parent_nesting), $String_encode_uri_component$3, $String_encode_uri$4, $String_decode_uri_component$5, $String_decode_uri$6; Opal.def(self, '$encode_uri_component', $String_encode_uri_component$3 = function $$encode_uri_component() { var self = this; return encodeURIComponent(self); }, $String_encode_uri_component$3.$$arity = 0); Opal.def(self, '$encode_uri', $String_encode_uri$4 = function $$encode_uri() { var self = this; return encodeURI(self); }, $String_encode_uri$4.$$arity = 0); Opal.def(self, '$decode_uri_component', $String_decode_uri_component$5 = function $$decode_uri_component() { var self = this; return decodeURIComponent(self); }, $String_decode_uri_component$5.$$arity = 0); return (Opal.def(self, '$decode_uri', $String_decode_uri$6 = function $$decode_uri() { var self = this; return decodeURI(self); }, $String_decode_uri$6.$$arity = 0), nil) && 'decode_uri'; })($nesting[0], null, $nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Hash'); var $nesting = [self].concat($parent_nesting), $Hash_decode_uri$7, $Hash_encode_uri$9; Opal.defs(self, '$decode_uri', $Hash_decode_uri$7 = function $$decode_uri(string) { var $$8, self = this; return self['$[]']($send(string.$split("&"), 'map', [], ($$8 = function(part){var self = $$8.$$s || this, $a, $b, name = nil, value = nil; if (part == null) { part = nil; }; $b = part.$split("="), $a = Opal.to_ary($b), (name = ($a[0] == null ? nil : $a[0])), (value = ($a[1] == null ? nil : $a[1])), $b; return [name.$decode_uri_component(), value.$decode_uri_component()];}, $$8.$$s = self, $$8.$$arity = 1, $$8))) }, $Hash_decode_uri$7.$$arity = 1); return (Opal.def(self, '$encode_uri', $Hash_encode_uri$9 = function $$encode_uri() { var $$10, self = this; return $send(self, 'map', [], ($$10 = function(name, value){var self = $$10.$$s || this; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return "" + (name.$to_s().$encode_uri_component()) + "=" + (value.$to_s().$encode_uri_component());}, $$10.$$s = self, $$10.$$arity = 2, $$10)).$join("&") }, $Hash_encode_uri$9.$$arity = 0), nil) && 'encode_uri'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/support"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy, $gvars = Opal.gvars; Opal.add_stubs(['$downcase', '$===', '$!', '$supports?']); Opal.const_set($nesting[0], 'BROWSER_ENGINE', (function() { try { return (/MSIE|WebKit|Presto|Gecko/.exec(navigator.userAgent)[0]).$downcase() } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return "unknown" } finally { Opal.pop_exception() } } else { throw $err; } }})()); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting), $Browser_supports$ques$1, $Browser_loaded$ques$2; self.support = {}; Opal.defs(self, '$supports?', $Browser_supports$ques$1 = function(feature) { var $a, self = this, support = nil, $case = nil; if (self.support == null) self.support = nil; if ($truthy((typeof(self.support[feature]) !== "undefined"))) { return self.support[feature]}; support = (function() {$case = feature; if ("MutationObserver"['$===']($case)) {return (typeof(window.MutationObserver) !== "undefined")} else if ("WebSocket"['$===']($case)) {return (typeof(window.WebSocket) !== "undefined")} else if ("EventSource"['$===']($case)) {return (typeof(window.EventSource) !== "undefined")} else if ("XHR"['$===']($case)) {return (typeof(window.XMLHttpRequest) !== "undefined")} else if ("ActiveX"['$===']($case)) {return (typeof(window.ActiveXObject) !== "undefined")} else if ("WebSQL"['$===']($case)) {return (typeof(window.openDatabase) !== "undefined")} else if ("Query.css"['$===']($case)) {return (typeof(document.querySelectorAll) !== "undefined")} else if ("Query.xpath"['$===']($case)) {return (typeof(document.evaluate) !== "undefined")} else if ("Storage.local"['$===']($case)) {return (typeof(window.localStorage) !== "undefined")} else if ("Storage.global"['$===']($case)) {return (typeof(window.globalStorage) !== "undefined")} else if ("Storage.session"['$===']($case)) {return (typeof(window.sessionStorage) !== "undefined")} else if ("Immediate"['$===']($case)) {return (typeof(window.setImmediate) !== "undefined")} else if ("Immediate (Internet Explorer)"['$===']($case)) {return (typeof(window.msSetImmediate) !== "undefined")} else if ("Immediate (Firefox)"['$===']($case)) {return (typeof(window.mozSetImmediate) !== "undefined")} else if ("Immediate (Opera)"['$===']($case)) {return (typeof(window.oSetImmediate) !== "undefined")} else if ("Immediate (Chrome)"['$===']($case) || "setImmediate (Safari)"['$===']($case)) {return (typeof(window.webkitSetImmediate) !== "undefined")} else if ("CSS.computed"['$===']($case)) {return (typeof(window.getComputedStyle) !== "undefined")} else if ("CSS.current"['$===']($case)) {return (typeof(document.documentElement.currentStyle) !== "undefined")} else if ("Window.send"['$===']($case)) {return (typeof(window.postMessage) !== "undefined")} else if ("Window.send (Asynchronous)"['$===']($case)) {if ($truthy(($truthy($a = (typeof(window.postMessage) !== "undefined")) ? (typeof(window.importScripts) !== "undefined")['$!']() : $a))) { var ok = true, old = window.onmessage; window.onmessage = function() { ok = false; }; window.postMessage("", "*") window.onmessage = old; return ok; } else { return nil }} else if ("Window.send (Synchronous)"['$===']($case)) {return self['$supports?']("Window.send (Asynchronous)")['$!']()} else if ("Window.innerSize"['$===']($case)) {return (typeof(window.innerHeight) !== "undefined")} else if ("Window.outerSize"['$===']($case)) {return (typeof(window.outerHeight) !== "undefined")} else if ("Window.scroll"['$===']($case)) {return (typeof(document.documentElement.scrollLeft) !== "undefined")} else if ("Window.pageOffset"['$===']($case)) {return (typeof(window.pageXOffset) !== "undefined")} else if ("Attr.isId"['$===']($case)) { var div = document.createElement('div'); div.setAttribute('id', 'xxxxxxxxxxxxx'); return typeof(div.attributes['id'].isId) !== "undefined"; } else if ("Element.addBehavior"['$===']($case)) {return (typeof(document.documentElement.addBehavior) !== "undefined")} else if ("Element.className"['$===']($case)) { var div = document.createElement("div"); div.setAttribute('className', 'x'); return div.className === 'x'; } else if ("Element.class"['$===']($case)) { var div = document.createElement("div"); div.setAttribute('class', 'x'); return div.className === 'x'; } else if ("Element.for"['$===']($case)) { var label = document.createElement("label"); label.setAttribute('for', 'x'); return label.htmlFor === 'x'; } else if ("Element.htmlFor"['$===']($case)) { var label = document.createElement("label"); label.setAttribute('htmlFor', 'x'); return label.htmlFor === 'x'; } else if ("Element.clientSize"['$===']($case)) {return (typeof(document.documentElement.clientHeight) !== "undefined")} else if ("Element.scroll"['$===']($case)) {return (typeof(document.documentElement.scrollLeft) !== "undefined")} else if ("Element.textContent"['$===']($case)) {return (typeof(document.documentElement.textContent) !== "undefined")} else if ("Element.innerText"['$===']($case)) {return (typeof(document.documentElement.innerText) !== "undefined")} else if ("Element.matches"['$===']($case)) {return (typeof(document.documentElement.matches) !== "undefined")} else if ("Element.matches (Internet Explorer)"['$===']($case)) {return (typeof(document.documentElement.msMatchesSelector) !== "undefined")} else if ("Element.matches (Firefox)"['$===']($case)) {return (typeof(document.documentElement.mozMatchesSelector) !== "undefined")} else if ("Element.matches (Opera)"['$===']($case)) {return (typeof(document.documentElement.oMatchesSelector) !== "undefined")} else if ("Element.matches (Chrome)"['$===']($case) || "Element.matches (Safari)"['$===']($case)) {return (typeof(document.documentElement.webkitMatchesSelector) !== "undefined")} else if ("Element.getBoundingClientRect"['$===']($case)) {return (typeof(document.documentElement.getBoundingClientRect) !== "undefined")} else if ("Event.readystatechange"['$===']($case)) {return "onreadystatechange" in window.document.createElement("script");} else if ("Event.constructor"['$===']($case)) { try { new MouseEvent("click"); return true; } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return false } finally { Opal.pop_exception() } } else { throw $err; } };} else if ("Event.create"['$===']($case)) {return (typeof(document.createEvent) !== "undefined")} else if ("Event.createObject"['$===']($case)) {return (typeof(document.createEventObject) !== "undefined")} else if ("Event.addListener"['$===']($case)) {return (typeof(document.addEventListener) !== "undefined")} else if ("Event.attach"['$===']($case)) {return (typeof(document.attachEvent) !== "undefined")} else if ("Event.removeListener"['$===']($case)) {return (typeof(document.removeEventListener) !== "undefined")} else if ("Event.detach"['$===']($case)) {return (typeof(document.detachEvent) !== "undefined")} else if ("Event.dispatch"['$===']($case)) {return (typeof(document.dispatchEvent) !== "undefined")} else if ("Event.fire"['$===']($case)) {return (typeof(document.fireEvent) !== "undefined")} else if (/^Event\.([A-Z].*?)$/['$===']($case)) {return ((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)) + "Event") in window} else if ("Document.view"['$===']($case)) {return (typeof(document.defaultView) !== "undefined")} else if ("Document.window"['$===']($case)) {return (typeof(document.parentWindow) !== "undefined")} else if ("History"['$===']($case)) {return (typeof(window.history.pushState) !== "undefined")} else if ("History.state"['$===']($case)) {return (typeof(window.history.state) !== "undefined")} else if ("Animation.request"['$===']($case)) {return (typeof(window.requestAnimationFrame) !== "undefined")} else if ("Animation.request (Internet Explorer)"['$===']($case)) {return (typeof(window.msRequestAnimationFrame) !== "undefined")} else if ("Animation.request (Firefox)"['$===']($case)) {return (typeof(window.mozRequestAnimationFrame) !== "undefined")} else if ("Animation.request (Opera)"['$===']($case)) {return (typeof(window.oRequestAnimationFrame) !== "undefined")} else if ("Animation.request (Chrome)"['$===']($case) || "Animation.request (Safari)"['$===']($case)) {return (typeof(window.webkitRequestAnimationFrame) !== "undefined")} else if ("Animation.cancel"['$===']($case)) {return (typeof(window.cancelAnimationFrame) !== "undefined")} else if ("Animation.cancel (Internet Explorer)"['$===']($case)) {return (typeof(window.msCancelAnimationFrame) !== "undefined")} else if ("Animation.cancel (Firefox)"['$===']($case)) {return (typeof(window.mozCancelAnimationFrame) !== "undefined")} else if ("Animation.cancel (Opera)"['$===']($case)) {return (typeof(window.oCancelAnimationFrame) !== "undefined")} else if ("Animation.cancel (Chrome)"['$===']($case) || "Animation.cancel (Safari)"['$===']($case)) {return (typeof(window.webkitCancelAnimationFrame) !== "undefined")} else if ("Animation.cancelRequest"['$===']($case)) {return (typeof(window.cancelRequestAnimationFrame) !== "undefined")} else if ("Animation.cancelRequest (Internet Explorer)"['$===']($case)) {return (typeof(window.msCancelRequestAnimationFrame) !== "undefined")} else if ("Animation.cancelRequest (Firefox)"['$===']($case)) {return (typeof(window.mozCancelRequestAnimationFrame) !== "undefined")} else if ("Animation.cancelRequest (Opera)"['$===']($case)) {return (typeof(window.oCancelRequestAnimationFrame) !== "undefined")} else if ("Animation.cancelRequest (Chrome)"['$===']($case) || "Animation.cancelRequest (Safari)"['$===']($case)) {return (typeof(window.webkitCancelRequestAnimationFrame) !== "undefined")} else { return nil }})(); return self.support[feature] = support; }, $Browser_supports$ques$1.$$arity = 1); Opal.defs(self, '$loaded?', $Browser_loaded$ques$2 = function(name) { var self = this, $case = nil; return (function() {$case = name; if ("Sizzle"['$===']($case)) {return (typeof(window.Sizzle) !== "undefined")} else if ("wicked-good-xpath"['$===']($case)) {return (typeof(window.wgxpath) !== "undefined")} else { return nil }})() }, $Browser_loaded$ques$2.$$arity = 1); })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/base"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $lambda = Opal.lambda, $hash2 = Opal.hash2; Opal.add_stubs(['$include', '$call', '$to_n', '$<<', '$converters', '$native?', '$each', '$instance_eval', '$register', '$to_proc', '$attr_reader', '$new', '$stopped?', '$arguments', '$!', '$prevented?', '$class_for', '$off', '$target', '$[]', '$delegated', '$delete', '$last', '$empty?', '$first', '$raise', '$name_for', '$handlers', '$[]=', '$-', '$include?', '$on!', '$delegate', '$callback=', '$on', '$handlers=', '$push', '$callbacks', '$attach', '$attach!', '$supports?', '$name', '$==', '$event', '$===', '$warn', '$detach', '$gsub', '$delete_if', '$=~', '$clear', '$none?', '$is_a?', '$create', '$dispatch', '$trigger', '$bubbles=', '$private', '$nil?', '$dup', '$on=', '$parent']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); self.$include($$($nesting, 'Native')); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_new$1, $Definition_bubbles$eq$2, $Definition_cancelable$eq$3; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.defs(self, '$new', $Definition_new$1 = function() { var $iter = $Definition_new$1.$$p, block = $iter || nil, self = this, data = nil; if ($iter) $Definition_new$1.$$p = null; if ($iter) $Definition_new$1.$$p = null;; data = $send(self, Opal.find_super_dispatcher(self, 'new', $Definition_new$1, false, self.$$class.$$prototype), [{ bubbles: true, cancelable: true }], null); if ($truthy(block)) { block.$call(data)}; return data.$to_n(); }, $Definition_new$1.$$arity = 0); Opal.def(self, '$bubbles=', $Definition_bubbles$eq$2 = function(value) { var self = this; return self["native"].bubbles = value }, $Definition_bubbles$eq$2.$$arity = 1); return (Opal.def(self, '$cancelable=', $Definition_cancelable$eq$3 = function(value) { var self = this; return self["native"].cancelable = value }, $Definition_cancelable$eq$3.$$arity = 1), nil) && 'cancelable='; })($nesting[0], null, $nesting); return (function($base, $parent_nesting) { var self = $module($base, 'Target'); var $nesting = [self].concat($parent_nesting), $Target_converters$4, $Target_register$5, $Target_convert$6, $Target_included$8, $Target_on$19, $Target_on$excl$22, $Target_attach$23, $Target_attach$excl$24, $Target_attach$25, $Target_attach$excl$26, $Target_attach$27, $Target_attach$excl$28, $Target_off$29, $Target_detach$33, $Target_detach$34, $Target_detach$36, $Target_trigger$37, $Target_trigger$excl$38, $Target_dispatch$40, $Target_dispatch$41, $Target_dispatch$42, $Target_callbacks$43, $Target_delegated$44, $Target_delegate$45; Opal.defs(self, '$converters', $Target_converters$4 = function $$converters() { var $a, self = this; if (self.converters == null) self.converters = nil; return (self.converters = ($truthy($a = self.converters) ? $a : [])) }, $Target_converters$4.$$arity = 0); Opal.defs(self, '$register', $Target_register$5 = function $$register() { var $iter = $Target_register$5.$$p, block = $iter || nil, self = this; if ($iter) $Target_register$5.$$p = null; if ($iter) $Target_register$5.$$p = null;; return self.$converters()['$<<'](block); }, $Target_register$5.$$arity = 0); Opal.defs(self, '$convert', $Target_convert$6 = function $$convert(value) {try { var $$7, self = this; if ($truthy(self['$native?'](value))) { } else { return value }; $send(self.$converters(), 'each', [], ($$7 = function(block){var self = $$7.$$s || this, result = nil; if (block == null) { block = nil; }; if ($truthy((result = block.$call(value)))) { Opal.ret(result) } else { return nil };}, $$7.$$s = self, $$7.$$arity = 1, $$7)); return nil; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Target_convert$6.$$arity = 1); Opal.defs(self, '$included', $Target_included$8 = function $$included(klass) { var $$9, self = this; return $send(klass, 'instance_eval', [], ($$9 = function(){var self = $$9.$$s || this, $target$10; return (Opal.defs(self, '$target', $target$10 = function $$target() { var $iter = $target$10.$$p, block = $iter || nil, self = this; if ($iter) $target$10.$$p = null; if ($iter) $target$10.$$p = null;; return $send($$$($$($nesting, 'Event'), 'Target'), 'register', [], block.$to_proc()); }, $target$10.$$arity = 0), nil) && 'target'}, $$9.$$s = self, $$9.$$arity = 0, $$9)) }, $Target_included$8.$$arity = 1); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Callback'); var $nesting = [self].concat($parent_nesting), $Callback_initialize$11, $Callback_call$12, $Callback_to_proc$13, $Callback_event$15, $Callback_off$16; self.$$prototype.proc = self.$$prototype.name = nil; self.$attr_reader("target", "name", "selector"); Opal.def(self, '$initialize', $Callback_initialize$11 = function $$initialize(target, name, selector) { var $iter = $Callback_initialize$11.$$p, block = $iter || nil, self = this; if ($iter) $Callback_initialize$11.$$p = null; if ($iter) $Callback_initialize$11.$$p = null;; if (selector == null) { selector = nil; }; self.target = target; self.name = name; self.selector = selector; return (self.block = block); }, $Callback_initialize$11.$$arity = -3); Opal.def(self, '$call', $Callback_call$12 = function $$call(event) { var self = this; return self.$to_proc().$call(event) }, $Callback_call$12.$$arity = 1); Opal.def(self, '$to_proc', $Callback_to_proc$13 = function $$to_proc() { var $a, $$14, self = this; return (self.proc = ($truthy($a = self.proc) ? $a : $lambda(($$14 = function(event){var self = $$14.$$s || this; if (self.block == null) self.block = nil; if (event == null) { event = nil; }; if (!event.currentTarget) { event.currentTarget = self.target.native; } ; event = $$($nesting, 'Event').$new(event, self); if ($truthy(event['$stopped?']())) { } else { $send(self.block, 'call', [event].concat(Opal.to_a(event.$arguments()))) }; return event['$prevented?']()['$!']();}, $$14.$$s = self, $$14.$$arity = 1, $$14)))) }, $Callback_to_proc$13.$$arity = 0); Opal.def(self, '$event', $Callback_event$15 = function $$event() { var self = this; return $$($nesting, 'Event').$class_for(self.name) }, $Callback_event$15.$$arity = 0); return (Opal.def(self, '$off', $Callback_off$16 = function $$off() { var self = this; return self.$target().$off(self) }, $Callback_off$16.$$arity = 0), nil) && 'off'; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Delegate'); var $nesting = [self].concat($parent_nesting), $Delegate_initialize$17, $Delegate_off$18; self.$$prototype.target = self.$$prototype.name = self.$$prototype.pair = nil; Opal.def(self, '$initialize', $Delegate_initialize$17 = function $$initialize(target, name, pair) { var self = this; self.target = target; self.name = name; return (self.pair = pair); }, $Delegate_initialize$17.$$arity = 3); return (Opal.def(self, '$off', $Delegate_off$18 = function $$off() { var self = this, delegate = nil; delegate = self.target.$delegated()['$[]'](self.name); delegate.$last().$delete(self.pair); if ($truthy(delegate.$last()['$empty?']())) { delegate.$first().$off(); return delegate.$delete(self.name); } else { return nil }; }, $Delegate_off$18.$$arity = 0), nil) && 'off'; })($nesting[0], null, $nesting); Opal.const_set($nesting[0], 'Delegates', $$($nesting, 'Struct').$new("callback", "handlers")); Opal.def(self, '$on', $Target_on$19 = function $$on(name, selector) { var $iter = $Target_on$19.$$p, block = $iter || nil, $$20, $$21, self = this, delegate = nil, pair = nil, $writer = nil, callback = nil; if ($iter) $Target_on$19.$$p = null; if ($iter) $Target_on$19.$$p = null;; if (selector == null) { selector = nil; }; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "no block has been given") }; name = $$($nesting, 'Event').$name_for(name); if ($truthy(selector)) { if ($truthy((delegate = self.$delegated()['$[]'](name)))) { pair = [selector, block]; delegate.$handlers()['$<<'](pair); return $$($nesting, 'Delegate').$new(self, name, pair); } else { delegate = (($writer = [name, $$($nesting, 'Delegates').$new()]), $send(self.$delegated(), '[]=', Opal.to_a($writer)), $writer[$rb_minus($writer["length"], 1)]); if ($truthy(["blur", "focus"]['$include?'](name))) { $writer = [$send(self, 'on!', [name], ($$20 = function(e){var self = $$20.$$s || this; if (e == null) { e = nil; }; return self.$delegate(delegate, e);}, $$20.$$s = self, $$20.$$arity = 1, $$20))]; $send(delegate, 'callback=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; } else { $writer = [$send(self, 'on', [name], ($$21 = function(e){var self = $$21.$$s || this; if (e == null) { e = nil; }; return self.$delegate(delegate, e);}, $$21.$$s = self, $$21.$$arity = 1, $$21))]; $send(delegate, 'callback=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; }; pair = [selector, block]; $writer = [[pair]]; $send(delegate, 'handlers=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; return $$($nesting, 'Delegate').$new(self, name, pair); } } else { callback = $send($$($nesting, 'Callback'), 'new', [self, name, selector], block.$to_proc()); self.$callbacks().$push(callback); return self.$attach(callback); }; }, $Target_on$19.$$arity = -2); Opal.def(self, '$on!', $Target_on$excl$22 = function(name) { var $iter = $Target_on$excl$22.$$p, block = $iter || nil, self = this, callback = nil; if ($iter) $Target_on$excl$22.$$p = null; if ($iter) $Target_on$excl$22.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "no block has been given") }; name = $$($nesting, 'Event').$name_for(name); callback = $send($$($nesting, 'Callback'), 'new', [self, name], block.$to_proc()); self.$callbacks().$push(callback); return self['$attach!'](callback); }, $Target_on$excl$22.$$arity = 1); if ($truthy($$($nesting, 'Browser')['$supports?']("Event.addListener"))) { Opal.def(self, '$attach', $Target_attach$23 = function $$attach(callback) { var self = this; if (self["native"] == null) self["native"] = nil; self["native"].addEventListener(callback.$name(), callback.$to_proc()); return callback; }, $Target_attach$23.$$arity = 1); Opal.def(self, '$attach!', $Target_attach$excl$24 = function(callback) { var self = this; if (self["native"] == null) self["native"] = nil; self["native"].addEventListener(callback.$name(), callback.$to_proc(), true); return callback; }, $Target_attach$excl$24.$$arity = 1); } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.attach"))) { Opal.def(self, '$attach', $Target_attach$25 = function $$attach(callback) { var self = this; if (self["native"] == null) self["native"] = nil; if (callback.$event()['$==']($$($nesting, 'Custom'))) { if (!self["native"].$custom) { self["native"].$custom = function(event) { for (var i = 0, length = self["native"].$callbacks.length; i < length; i++) { var callback = self["native"].$callbacks[i]; if ((callback).$event()['$==']($$($nesting, 'Custom'))) { event.type = callback.name; (callback).$call(event); } } }; self["native"].attachEvent("ondataavailable", self["native"].$custom); } } else { self["native"].attachEvent("on" + callback.$name(), callback.$to_proc()) }; return callback; }, $Target_attach$25.$$arity = 1); Opal.def(self, '$attach!', $Target_attach$excl$26 = function(callback) { var self = this, $case = nil; if (self["native"] == null) self["native"] = nil; $case = callback.$name(); if ("blur"['$===']($case)) {self["native"].attachEvent("onfocusout", callback.$to_proc())} else if ("focus"['$===']($case)) {self["native"].attachEvent("onfocusin", callback.$to_proc())} else { self.$warn("attach: capture doesn't work on this browser"); self.$attach(callback);}; return callback; }, $Target_attach$excl$26.$$arity = 1); } else { Opal.def(self, '$attach', $Target_attach$27 = function $$attach($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError')); }, $Target_attach$27.$$arity = -1); Opal.def(self, '$attach!', $Target_attach$excl$28 = function($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError')); }, $Target_attach$excl$28.$$arity = -1); }; Opal.def(self, '$off', $Target_off$29 = function $$off(what) { var $a, $$30, $$31, $$32, self = this, $case = nil; if (what == null) { what = nil; }; return (function() {$case = what; if ($$($nesting, 'Callback')['$===']($case)) { self.$callbacks().$delete(what); return self.$detach(what);} else if ($$($nesting, 'String')['$===']($case)) {if ($truthy(($truthy($a = what['$include?']("*")) ? $a : what['$include?']("?")))) { return self.$off($$($nesting, 'Regexp').$new(what.$gsub(/\*/, ".*?").$gsub(/\?/, "."))) } else { what = $$($nesting, 'Event').$name_for(what); return $send(self.$callbacks(), 'delete_if', [], ($$30 = function(callback){var self = $$30.$$s || this; if (callback == null) { callback = nil; }; if (callback.$name()['$=='](what)) { self.$detach(callback); return true; } else { return nil };}, $$30.$$s = self, $$30.$$arity = 1, $$30)); }} else if ($$($nesting, 'Regexp')['$===']($case)) {return $send(self.$callbacks(), 'delete_if', [], ($$31 = function(callback){var self = $$31.$$s || this; if (callback == null) { callback = nil; }; if ($truthy(callback.$name()['$=~'](what))) { self.$detach(callback); return true; } else { return nil };}, $$31.$$s = self, $$31.$$arity = 1, $$31))} else { $send(self.$callbacks(), 'each', [], ($$32 = function(callback){var self = $$32.$$s || this; if (callback == null) { callback = nil; }; return self.$detach(callback);}, $$32.$$s = self, $$32.$$arity = 1, $$32)); return self.$callbacks().$clear();}})(); }, $Target_off$29.$$arity = -1); if ($truthy($$($nesting, 'Browser')['$supports?']("Event.removeListener"))) { Opal.def(self, '$detach', $Target_detach$33 = function $$detach(callback) { var self = this; if (self["native"] == null) self["native"] = nil; return self["native"].removeEventListener(callback.$name(), callback.$to_proc(), false) }, $Target_detach$33.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.detach"))) { Opal.def(self, '$detach', $Target_detach$34 = function $$detach(callback) { var $$35, self = this; if (self["native"] == null) self["native"] = nil; if (callback.$event()['$==']($$($nesting, 'Custom'))) { if ($truthy($send(self.$callbacks(), 'none?', [], ($$35 = function(c){var self = $$35.$$s || this; if (c == null) { c = nil; }; return c.$event()['$==']($$($nesting, 'Custom'));}, $$35.$$s = self, $$35.$$arity = 1, $$35)))) { self["native"].detachEvent("ondataavailable", self["native"].$custom); delete self["native"].$custom; } else { return nil } } else { return self["native"].detachEvent("on" + callback.$name(), callback.$to_proc()) } }, $Target_detach$34.$$arity = 1) } else { Opal.def(self, '$detach', $Target_detach$36 = function $$detach(callback) { var self = this; return self.$raise($$($nesting, 'NotImplementedError')) }, $Target_detach$36.$$arity = 1) }; Opal.def(self, '$trigger', $Target_trigger$37 = function $$trigger(event, $a) { var $iter = $Target_trigger$37.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Target_trigger$37.$$p = null; if ($iter) $Target_trigger$37.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(event['$is_a?']($$($nesting, 'String')))) { event = $send($$($nesting, 'Event'), 'create', [event].concat(Opal.to_a(args)), block.$to_proc())}; return self.$dispatch(event); }, $Target_trigger$37.$$arity = -2); Opal.def(self, '$trigger!', $Target_trigger$excl$38 = function(event, $a) { var $iter = $Target_trigger$excl$38.$$p, block = $iter || nil, $post_args, args, $$39, self = this; if ($iter) $Target_trigger$excl$38.$$p = null; if ($iter) $Target_trigger$excl$38.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; return $send(self, 'trigger', [event].concat(Opal.to_a(args)), ($$39 = function(e){var self = $$39.$$s || this, $writer = nil; if (e == null) { e = nil; }; if ($truthy(block)) { block.$call(e)}; $writer = [false]; $send(e, 'bubbles=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];;}, $$39.$$s = self, $$39.$$arity = 1, $$39)); }, $Target_trigger$excl$38.$$arity = -2); if ($truthy($$($nesting, 'Browser')['$supports?']("Event.dispatch"))) { Opal.def(self, '$dispatch', $Target_dispatch$40 = function $$dispatch(event) { var self = this; if (self["native"] == null) self["native"] = nil; return self["native"].dispatchEvent(event.$to_n()) }, $Target_dispatch$40.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.fire"))) { Opal.def(self, '$dispatch', $Target_dispatch$41 = function $$dispatch(event) { var self = this; if (self["native"] == null) self["native"] = nil; if ($truthy($$($nesting, 'Custom')['$==='](event))) { return self["native"].fireEvent("ondataavailable", event.$to_n()) } else { return self["native"].fireEvent("on" + event.$name(), event.$to_n()) } }, $Target_dispatch$41.$$arity = 1) } else { Opal.def(self, '$dispatch', $Target_dispatch$42 = function $$dispatch($a) { var $post_args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); ; return self.$raise($$($nesting, 'NotImplementedError')); }, $Target_dispatch$42.$$arity = -1) }; self.$private(); Opal.def(self, '$callbacks', $Target_callbacks$43 = function $$callbacks() { var self = this; if (self["native"] == null) self["native"] = nil; if (!self["native"].$callbacks) { self["native"].$callbacks = []; } return self["native"].$callbacks; }, $Target_callbacks$43.$$arity = 0); Opal.def(self, '$delegated', $Target_delegated$44 = function $$delegated() { var self = this; if (self["native"] == null) self["native"] = nil; if (!self["native"].$delegated) { self["native"].$delegated = $hash2([], {}); } return self["native"].$delegated; }, $Target_delegated$44.$$arity = 0); Opal.def(self, '$delegate', $Target_delegate$45 = function $$delegate(delegates, event, element) { var $a, $$46, self = this; if (element == null) { element = event.$target(); }; if ($truthy(($truthy($a = element['$nil?']()) ? $a : element['$=='](event.$on())))) { return nil}; $send(delegates.$handlers(), 'each', [], ($$46 = function(selector, block){var self = $$46.$$s || this, new$ = nil, $writer = nil; if (selector == null) { selector = nil; }; if (block == null) { block = nil; }; if ($truthy(element['$=~'](selector))) { new$ = event.$dup(); $writer = [element]; $send(new$, 'on=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; return $send(block, 'call', [new$].concat(Opal.to_a(new$.$arguments()))); } else { return nil };}, $$46.$$s = self, $$46.$$arity = 2, $$46)); return self.$delegate(delegates, event, element.$parent()); }, $Target_delegate$45.$$arity = -3); })($nesting[0], $nesting); })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/ui"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'UI'); var $nesting = [self].concat($parent_nesting), $UI_supported$ques$1, $UI_construct$4, $UI_construct$5; Opal.defs(self, '$supported?', $UI_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.UI") }, $UI_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_detail$eq$2, $Definition_view$eq$3; self.$$prototype["native"] = nil; Opal.def(self, '$detail=', $Definition_detail$eq$2 = function(value) { var self = this; return self["native"].detail = value }, $Definition_detail$eq$2.$$arity = 1); return (Opal.def(self, '$view=', $Definition_view$eq$3 = function(value) { var self = this; return self["native"].view = value }, $Definition_view$eq$3.$$arity = 1), nil) && 'view='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $UI_construct$4 = function $$construct(name, desc) { var self = this; return new UIEvent(name, desc) }, $UI_construct$4.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $UI_construct$5 = function $$construct(name, desc) { var self = this; var event = document.createEvent("UIEvent"); event.initUIEvent(name, desc.bubbles, desc.cancelable, desc.view || window, desc.detail || 0); return event; }, $UI_construct$5.$$arity = 2)}}; self.$alias_native("detail"); return self.$alias_native("view"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/mouse"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $gvars = Opal.gvars, $truthy = Opal.truthy; Opal.add_stubs(['$!', '$nil?', '$[]', '$include', '$new', '$try_convert', '$supported?', '$supports?', '$alias_native', '$x', '$screen', '$y', '$DOM', '$==', '$downcase', '$name']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Mouse'); var $nesting = [self].concat($parent_nesting), $Mouse_supported$ques$1, $Mouse_construct$29, $Mouse_construct$30, $Mouse_client$31, $Mouse_layer$32, $Mouse_offset$33, $Mouse_page$34, $Mouse_screen$35, $Mouse_ancestor$36, $Mouse_x$37, $Mouse_y$38, $Mouse_related$39, $Mouse_from$40, $Mouse_to$41, $Mouse_click$ques$42, $Mouse_double_click$ques$43, $Mouse_down$ques$44, $Mouse_enter$ques$45, $Mouse_leave$ques$46, $Mouse_move$ques$47, $Mouse_out$ques$48, $Mouse_over$ques$49, $Mouse_up$ques$50, $Mouse_show$ques$51; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $Mouse_supported$ques$1 = function() { var self = this; if ($gvars.$ == null) $gvars.$ = nil; return $gvars.$['$[]']("MouseEvent")['$nil?']()['$!']() }, $Mouse_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_x$eq$14, $Definition_y$eq$15, $Definition_alt$excl$16, $Definition_ctrl$excl$17, $Definition_meta$excl$18, $Definition_button$eq$19, $Definition_client$20, $Definition_layer$21, $Definition_offset$22, $Definition_page$23, $Definition_screen$24, $Definition_ancestor$25, $Definition_related$eq$26, $Definition_from$eq$27, $Definition_to$eq$28; self.$$prototype["native"] = nil; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Client'); var $nesting = [self].concat($parent_nesting), $Client_x$eq$2, $Client_y$eq$3; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Client_x$eq$2 = function(value) { var self = this; return self["native"].clientX = value }, $Client_x$eq$2.$$arity = 1); return (Opal.def(self, '$y=', $Client_y$eq$3 = function(value) { var self = this; return self["native"].clientY = value }, $Client_y$eq$3.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Layer'); var $nesting = [self].concat($parent_nesting), $Layer_x$eq$4, $Layer_y$eq$5; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Layer_x$eq$4 = function(value) { var self = this; return self["native"].layerX = value }, $Layer_x$eq$4.$$arity = 1); return (Opal.def(self, '$y=', $Layer_y$eq$5 = function(value) { var self = this; return self["native"].layerY = value }, $Layer_y$eq$5.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Offset'); var $nesting = [self].concat($parent_nesting), $Offset_x$eq$6, $Offset_y$eq$7; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Offset_x$eq$6 = function(value) { var self = this; return self["native"].offsetX = value }, $Offset_x$eq$6.$$arity = 1); return (Opal.def(self, '$y=', $Offset_y$eq$7 = function(value) { var self = this; return self["native"].offsetY= value }, $Offset_y$eq$7.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Page'); var $nesting = [self].concat($parent_nesting), $Page_x$eq$8, $Page_y$eq$9; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Page_x$eq$8 = function(value) { var self = this; return self["native"].pageX = value }, $Page_x$eq$8.$$arity = 1); return (Opal.def(self, '$y=', $Page_y$eq$9 = function(value) { var self = this; return self["native"].pageY = value }, $Page_y$eq$9.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Screen'); var $nesting = [self].concat($parent_nesting), $Screen_x$eq$10, $Screen_y$eq$11; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Screen_x$eq$10 = function(value) { var self = this; return self["native"].screenX = value }, $Screen_x$eq$10.$$arity = 1); return (Opal.def(self, '$y=', $Screen_y$eq$11 = function(value) { var self = this; return self["native"].screenY = value }, $Screen_y$eq$11.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Ancestor'); var $nesting = [self].concat($parent_nesting), $Ancestor_x$eq$12, $Ancestor_y$eq$13; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Ancestor_x$eq$12 = function(value) { var self = this; return self["native"].x = value }, $Ancestor_x$eq$12.$$arity = 1); return (Opal.def(self, '$y=', $Ancestor_y$eq$13 = function(value) { var self = this; return self["native"].y = value }, $Ancestor_y$eq$13.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); Opal.def(self, '$x=', $Definition_x$eq$14 = function(value) { var self = this; return self["native"].screenX = value }, $Definition_x$eq$14.$$arity = 1); Opal.def(self, '$y=', $Definition_y$eq$15 = function(value) { var self = this; return self["native"].screenY = value }, $Definition_y$eq$15.$$arity = 1); Opal.def(self, '$alt!', $Definition_alt$excl$16 = function() { var self = this; return self["native"].altKey = true }, $Definition_alt$excl$16.$$arity = 0); Opal.def(self, '$ctrl!', $Definition_ctrl$excl$17 = function() { var self = this; return self["native"].ctrlKey = true }, $Definition_ctrl$excl$17.$$arity = 0); Opal.def(self, '$meta!', $Definition_meta$excl$18 = function() { var self = this; return self["native"].metaKey = true }, $Definition_meta$excl$18.$$arity = 0); Opal.def(self, '$button=', $Definition_button$eq$19 = function(value) { var self = this; return self["native"].button = value }, $Definition_button$eq$19.$$arity = 1); Opal.def(self, '$client', $Definition_client$20 = function $$client() { var self = this; return $$($nesting, 'Client').$new(self["native"]) }, $Definition_client$20.$$arity = 0); Opal.def(self, '$layer', $Definition_layer$21 = function $$layer() { var self = this; return $$($nesting, 'Layer').$new(self["native"]) }, $Definition_layer$21.$$arity = 0); Opal.def(self, '$offset', $Definition_offset$22 = function $$offset() { var self = this; return $$($nesting, 'Offset').$new(self["native"]) }, $Definition_offset$22.$$arity = 0); Opal.def(self, '$page', $Definition_page$23 = function $$page() { var self = this; return $$($nesting, 'Page').$new(self["native"]) }, $Definition_page$23.$$arity = 0); Opal.def(self, '$screen', $Definition_screen$24 = function $$screen() { var self = this; return $$($nesting, 'Screen').$new(self["native"]) }, $Definition_screen$24.$$arity = 0); Opal.def(self, '$ancestor', $Definition_ancestor$25 = function $$ancestor() { var self = this; return $$($nesting, 'Ancestor').$new(self["native"]) }, $Definition_ancestor$25.$$arity = 0); Opal.def(self, '$related=', $Definition_related$eq$26 = function(elem) { var self = this; return self["native"].relatedTarget = $$($nesting, 'Native').$try_convert(elem) }, $Definition_related$eq$26.$$arity = 1); Opal.def(self, '$from=', $Definition_from$eq$27 = function(elem) { var self = this; return self["native"].fromElement = $$($nesting, 'Native').$try_convert(elem) }, $Definition_from$eq$27.$$arity = 1); return (Opal.def(self, '$to=', $Definition_to$eq$28 = function(elem) { var self = this; return self["native"].toElement = $$($nesting, 'Native').$try_convert(elem) }, $Definition_to$eq$28.$$arity = 1), nil) && 'to='; })($nesting[0], $$$($$($nesting, 'UI'), 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Mouse_construct$29 = function $$construct(name, desc) { var self = this; return new MouseEvent(name, desc) }, $Mouse_construct$29.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Mouse_construct$30 = function $$construct(name, desc) { var self = this; var event = document.createEvent("MouseEvent"); event.initMouseEvent(name, desc.bubbles, desc.cancelable, desc.view || window, desc.detail || 0, desc.screenX || 0, desc.screenY || 0, desc.clientX || 0, desc.clientY || 0, desc.ctrlKey || false, desc.altKey || false, desc.shiftKey || false, desc.metaKey || false, desc.button || 0, desc.relatedTarget || null); return event; }, $Mouse_construct$30.$$arity = 2)}}; self.$alias_native("alt?", "altKey"); self.$alias_native("ctrl?", "ctrlKey"); self.$alias_native("meta?", "metaKey"); self.$alias_native("shift?", "shiftKey"); self.$alias_native("button"); Opal.def(self, '$client', $Mouse_client$31 = function $$client() { var self = this; return $$($nesting, 'Position').$new(self["native"].clientX, self["native"].clientY) }, $Mouse_client$31.$$arity = 0); Opal.def(self, '$layer', $Mouse_layer$32 = function $$layer() { var self = this; if ($truthy(self["native"].layerX == null)) { return nil } else { return $$($nesting, 'Position').$new(self["native"].layerX, self["native"].layerY) } }, $Mouse_layer$32.$$arity = 0); Opal.def(self, '$offset', $Mouse_offset$33 = function $$offset() { var self = this; if ($truthy(self["native"].offsetX == null)) { return nil } else { return $$($nesting, 'Position').$new(self["native"].offsetX, self["native"].offsetY) } }, $Mouse_offset$33.$$arity = 0); Opal.def(self, '$page', $Mouse_page$34 = function $$page() { var self = this; if ($truthy(self["native"].pageX == null)) { return nil } else { return $$($nesting, 'Position').$new(self["native"].pageX, self["native"].pageY) } }, $Mouse_page$34.$$arity = 0); Opal.def(self, '$screen', $Mouse_screen$35 = function $$screen() { var self = this; if ($truthy(self["native"].screenX == null)) { return nil } else { return $$($nesting, 'Position').$new(self["native"].screenX, self["native"].screenY) } }, $Mouse_screen$35.$$arity = 0); Opal.def(self, '$ancestor', $Mouse_ancestor$36 = function $$ancestor() { var self = this; if ($truthy(self["native"].x == null)) { return nil } else { return $$($nesting, 'Position').$new(self["native"].x, self["native"].y) } }, $Mouse_ancestor$36.$$arity = 0); Opal.def(self, '$x', $Mouse_x$37 = function $$x() { var self = this; return self.$screen().$x() }, $Mouse_x$37.$$arity = 0); Opal.def(self, '$y', $Mouse_y$38 = function $$y() { var self = this; return self.$screen().$y() }, $Mouse_y$38.$$arity = 0); Opal.def(self, '$related', $Mouse_related$39 = function $$related() { var self = this; if ($truthy(self["native"].relatedTarget == null)) { return nil } else { return self.$DOM(self["native"].relatedTarget) } }, $Mouse_related$39.$$arity = 0); Opal.def(self, '$from', $Mouse_from$40 = function $$from() { var self = this; if ($truthy(self["native"].fromElement == null)) { return nil } else { return self.$DOM(self["native"].fromElement) } }, $Mouse_from$40.$$arity = 0); Opal.def(self, '$to', $Mouse_to$41 = function $$to() { var self = this; if ($truthy(self["native"].toElement == null)) { return nil } else { return self.$DOM(self["native"].toElement) } }, $Mouse_to$41.$$arity = 0); Opal.def(self, '$click?', $Mouse_click$ques$42 = function() { var self = this; return self.$name().$downcase()['$==']("click") }, $Mouse_click$ques$42.$$arity = 0); Opal.def(self, '$double_click?', $Mouse_double_click$ques$43 = function() { var self = this; return self.$name().$downcase()['$==']("dblclick") }, $Mouse_double_click$ques$43.$$arity = 0); Opal.def(self, '$down?', $Mouse_down$ques$44 = function() { var self = this; return self.$name().$downcase()['$==']("mousedown") }, $Mouse_down$ques$44.$$arity = 0); Opal.def(self, '$enter?', $Mouse_enter$ques$45 = function() { var self = this; return self.$name().$downcase()['$==']("mouseenter") }, $Mouse_enter$ques$45.$$arity = 0); Opal.def(self, '$leave?', $Mouse_leave$ques$46 = function() { var self = this; return self.$name().$downcase()['$==']("mouseleave") }, $Mouse_leave$ques$46.$$arity = 0); Opal.def(self, '$move?', $Mouse_move$ques$47 = function() { var self = this; return self.$name().$downcase()['$==']("mousemove") }, $Mouse_move$ques$47.$$arity = 0); Opal.def(self, '$out?', $Mouse_out$ques$48 = function() { var self = this; return self.$name().$downcase()['$==']("mouseout") }, $Mouse_out$ques$48.$$arity = 0); Opal.def(self, '$over?', $Mouse_over$ques$49 = function() { var self = this; return self.$name().$downcase()['$==']("mouseover") }, $Mouse_over$ques$49.$$arity = 0); Opal.def(self, '$up?', $Mouse_up$ques$50 = function() { var self = this; return self.$name().$downcase()['$==']("mouseup") }, $Mouse_up$ques$50.$$arity = 0); return (Opal.def(self, '$show?', $Mouse_show$ques$51 = function() { var self = this; return self.$name().$downcase()['$==']("show") }, $Mouse_show$ques$51.$$arity = 0), nil) && 'show?'; })($nesting[0], $$($nesting, 'UI'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/keyboard"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native', '$code', '$chr', '$==', '$downcase', '$name']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Keyboard'); var $nesting = [self].concat($parent_nesting), $Keyboard_supported$ques$1, $Keyboard_construct$11, $Keyboard_construct$12, $Keyboard_key$13, $Keyboard_code$14, $Keyboard_char$15, $Keyboard_down$ques$16, $Keyboard_press$ques$17, $Keyboard_up$ques$18; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $Keyboard_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Keyboard") }, $Keyboard_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_alt$excl$2, $Definition_ctrl$excl$3, $Definition_meta$excl$4, $Definition_shift$excl$5, $Definition_code$eq$6, $Definition_key$eq$7, $Definition_char$eq$8, $Definition_repeat$excl$9, $Definition_locale$eq$10; self.$$prototype["native"] = nil; Opal.def(self, '$alt!', $Definition_alt$excl$2 = function() { var self = this; return self["native"].altKey = true }, $Definition_alt$excl$2.$$arity = 0); Opal.def(self, '$ctrl!', $Definition_ctrl$excl$3 = function() { var self = this; return self["native"].ctrlKey = true }, $Definition_ctrl$excl$3.$$arity = 0); Opal.def(self, '$meta!', $Definition_meta$excl$4 = function() { var self = this; return self["native"].metaKey = true }, $Definition_meta$excl$4.$$arity = 0); Opal.def(self, '$shift!', $Definition_shift$excl$5 = function() { var self = this; return self["native"].shiftKey = true }, $Definition_shift$excl$5.$$arity = 0); Opal.def(self, '$code=', $Definition_code$eq$6 = function(code) { var self = this; return self["native"].keyCode = self["native"].which = code }, $Definition_code$eq$6.$$arity = 1); Opal.def(self, '$key=', $Definition_key$eq$7 = function(key) { var self = this; return self["native"].key = key }, $Definition_key$eq$7.$$arity = 1); Opal.def(self, '$char=', $Definition_char$eq$8 = function(char$) { var self = this; return self["native"].char = self["native"].charCode = char$ }, $Definition_char$eq$8.$$arity = 1); Opal.def(self, '$repeat!', $Definition_repeat$excl$9 = function() { var self = this; return self["native"].repeat = true }, $Definition_repeat$excl$9.$$arity = 0); return (Opal.def(self, '$locale=', $Definition_locale$eq$10 = function(value) { var self = this; return self["native"].locale = value }, $Definition_locale$eq$10.$$arity = 1), nil) && 'locale='; })($nesting[0], $$$($$($nesting, 'UI'), 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Keyboard_construct$11 = function $$construct(name, desc) { var self = this; return new KeyboardEvent(name, desc) }, $Keyboard_construct$11.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Keyboard_construct$12 = function $$construct(name, desc) { var self = this; var modifiers = ""; if (desc.altKey) { modifiers += "Alt "; } if (desc.ctrlKey) { modifiers += "Ctrl "; } if (desc.shiftKey) { modifiers += "Shift" ; } if (desc.metaKey) { modifiers += "Meta "; } var event = document.createEvent("KeyboardEvent"); event.initKeyboardEvent(name, desc.bubbles, desc.cancelable, desc.view || window, desc.which, 0, modifiers, desc.repeat, desc.locale); return event; }, $Keyboard_construct$12.$$arity = 2)}}; self.$alias_native("alt?", "altKey"); self.$alias_native("ctrl?", "ctrlKey"); self.$alias_native("meta?", "metaKey"); self.$alias_native("shift?", "shiftKey"); self.$alias_native("locale"); self.$alias_native("repeat?", "repeat"); Opal.def(self, '$key', $Keyboard_key$13 = function $$key() { var self = this; return self["native"].key || self["native"].keyIdentifier || nil }, $Keyboard_key$13.$$arity = 0); Opal.def(self, '$code', $Keyboard_code$14 = function $$code() { var self = this; return self["native"].keyCode || self["native"].which || nil }, $Keyboard_code$14.$$arity = 0); Opal.def(self, '$char', $Keyboard_char$15 = function() { var self = this; return self["native"].char || self["native"].charCode || (function() {if ($truthy(self.$code())) { return self.$code().$chr() } else { return nil }; return nil; })() }, $Keyboard_char$15.$$arity = 0); Opal.alias(self, "to_i", "key"); Opal.def(self, '$down?', $Keyboard_down$ques$16 = function() { var self = this; return self.$name().$downcase()['$==']("keydown") }, $Keyboard_down$ques$16.$$arity = 0); Opal.def(self, '$press?', $Keyboard_press$ques$17 = function() { var self = this; return self.$name().$downcase()['$==']("keypress") }, $Keyboard_press$ques$17.$$arity = 0); return (Opal.def(self, '$up?', $Keyboard_up$ques$18 = function() { var self = this; return self.$name().$downcase()['$==']("keyup") }, $Keyboard_up$ques$18.$$arity = 0), nil) && 'up?'; })($nesting[0], $$($nesting, 'UI'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/focus"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$convert', '$supported?', '$DOM']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Focus'); var $nesting = [self].concat($parent_nesting), $Focus_supported$ques$1, $Focus_construct$4, $Focus_construct$5, $Focus_related$6; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $Focus_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Focus") }, $Focus_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_view$eq$2, $Definition_related$eq$3; self.$$prototype["native"] = nil; Opal.def(self, '$view=', $Definition_view$eq$2 = function(value) { var self = this; return self["native"].view = $$($nesting, 'Native').$convert(value) }, $Definition_view$eq$2.$$arity = 1); return (Opal.def(self, '$related=', $Definition_related$eq$3 = function(elem) { var self = this; return self["native"].relatedTarget = $$($nesting, 'Native').$convert(elem) }, $Definition_related$eq$3.$$arity = 1), nil) && 'related='; })($nesting[0], $$$($$($nesting, 'UI'), 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Focus_construct$4 = function $$construct(name, desc) { var self = this; return new FocusEvent(name, desc) }, $Focus_construct$4.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Focus_construct$5 = function $$construct(name, desc) { var self = this; var event = document.createEvent("FocusEvent"); event.initFocusEvent(name, desc.bubbles, desc.cancelable, desc.view || window, 0, desc.relatedTarget); return event; }, $Focus_construct$5.$$arity = 2)}}; return (Opal.def(self, '$related', $Focus_related$6 = function $$related() { var self = this; return self.$DOM(self["native"].relatedTarget) }, $Focus_related$6.$$arity = 0), nil) && 'related'; })($nesting[0], $$($nesting, 'UI'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/wheel"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $gvars = Opal.gvars; Opal.add_stubs(['$!', '$nil?', '$[]', '$===', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Wheel'); var $nesting = [self].concat($parent_nesting), $Wheel_supported$ques$1, $Wheel_construct$6, $Wheel_mode$7; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $Wheel_supported$ques$1 = function() { var self = this; if ($gvars.$ == null) $gvars.$ = nil; return $gvars.$['$[]']("WheelEvent")['$nil?']()['$!']() }, $Wheel_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_x$eq$2, $Definition_y$eq$3, $Definition_z$eq$4, $Definition_mode$eq$5; self.$$prototype["native"] = nil; Opal.def(self, '$x=', $Definition_x$eq$2 = function(value) { var self = this; return self["native"].deltaX = value }, $Definition_x$eq$2.$$arity = 1); Opal.def(self, '$y=', $Definition_y$eq$3 = function(value) { var self = this; return self["native"].deltaY = value }, $Definition_y$eq$3.$$arity = 1); Opal.def(self, '$z=', $Definition_z$eq$4 = function(value) { var self = this; return self["native"].deltaZ = value }, $Definition_z$eq$4.$$arity = 1); return (Opal.def(self, '$mode=', $Definition_mode$eq$5 = function(value) { var self = this, $case = nil; value = (function() {$case = value; if ("pixel"['$===']($case)) {return WheelEvent.DOM_DELTA_PIXEL;} else if ("line"['$===']($case)) {return WheelEvent.DOM_DELTA_LINE;} else if ("page"['$===']($case)) {return WheelEvent.DOM_DELTA_PAGE;} else { return nil }})(); return self["native"].deltaMode = value; }, $Definition_mode$eq$5.$$arity = 1), nil) && 'mode='; })($nesting[0], $$($nesting, 'Definition'), $nesting); Opal.defs(self, '$construct', $Wheel_construct$6 = function $$construct(name, desc) { var self = this; return new WheelEvent(name, desc) }, $Wheel_construct$6.$$arity = 2); self.$alias_native("x", "deltaX"); self.$alias_native("y", "deltaY"); self.$alias_native("z", "deltaZ"); return (Opal.def(self, '$mode', $Wheel_mode$7 = function $$mode() { var self = this, $case = nil; return (function() {$case = self["native"].deltaMode; if ((WheelEvent.DOM_DELTA_PIXEL)['$===']($case)) {return "pixel"} else if ((WheelEvent.DOM_DELTA_LINE)['$===']($case)) {return "line"} else if ((WheelEvent.DOM_DELTA_PAGE)['$===']($case)) {return "page"} else { return nil }})() }, $Wheel_mode$7.$$arity = 0), nil) && 'mode'; })($nesting[0], $$($nesting, 'UI'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/composition"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native', '$==', '$downcase', '$name']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Composition'); var $nesting = [self].concat($parent_nesting), $Composition_supported$ques$1, $Composition_construct$4, $Composition_construct$5, $Composition_start$ques$6, $Composition_update$ques$7, $Composition_end$ques$8; Opal.defs(self, '$supported?', $Composition_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Composition") }, $Composition_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_data$eq$2, $Definition_locale$eq$3; self.$$prototype["native"] = nil; Opal.def(self, '$data=', $Definition_data$eq$2 = function(value) { var self = this; return self["native"].data = value }, $Definition_data$eq$2.$$arity = 1); return (Opal.def(self, '$locale=', $Definition_locale$eq$3 = function(value) { var self = this; return self["native"].locale = value }, $Definition_locale$eq$3.$$arity = 1), nil) && 'locale='; })($nesting[0], $$$($$($nesting, 'UI'), 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Composition_construct$4 = function $$construct(name, desc) { var self = this; return new CompositionEvent(name, desc) }, $Composition_construct$4.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Composition_construct$5 = function $$construct(name, desc) { var self = this; var event = document.createEvent("CompositionEvent"); event.initCompositionEvent(name, desc.bubbles, desc.cancelable, desc.view || window, desc.data, desc.locale); return event; }, $Composition_construct$5.$$arity = 2)}}; self.$alias_native("data"); self.$alias_native("locale"); Opal.def(self, '$start?', $Composition_start$ques$6 = function() { var self = this; return self.$name().$downcase()['$==']("compositionstart") }, $Composition_start$ques$6.$$arity = 0); Opal.def(self, '$update?', $Composition_update$ques$7 = function() { var self = this; return self.$name().$downcase()['$==']("compositionupdate") }, $Composition_update$ques$7.$$arity = 0); return (Opal.def(self, '$end?', $Composition_end$ques$8 = function() { var self = this; return self.$name().$downcase()['$==']("compositionend") }, $Composition_end$ques$8.$$arity = 0), nil) && 'end?'; })($nesting[0], $$($nesting, 'UI'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/animation"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Animation'); var $nesting = [self].concat($parent_nesting), $Animation_supported$ques$1, $Animation_construct$4, $Animation_construct$5; Opal.defs(self, '$supported?', $Animation_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Animation") }, $Animation_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_animation$eq$2, $Definition_elapsed$eq$3; self.$$prototype["native"] = nil; Opal.def(self, '$animation=', $Definition_animation$eq$2 = function(value) { var self = this; return self["native"].animationName = value }, $Definition_animation$eq$2.$$arity = 1); return (Opal.def(self, '$elapsed=', $Definition_elapsed$eq$3 = function(value) { var self = this; return self["native"].elapsedTime = value }, $Definition_elapsed$eq$3.$$arity = 1), nil) && 'elapsed='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Animation_construct$4 = function $$construct(name, desc) { var self = this; return new AnimationEvent(name, desc) }, $Animation_construct$4.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Animation_construct$5 = function $$construct(name, desc) { var self = this; var event = document.createEvent("AnimationEvent"); event.initAnimationEvent(name, desc.bubbles, desc.cancelable, desc.animationName, desc.elapsedTime); return event; }, $Animation_construct$5.$$arity = 2)}}; self.$alias_native("name", "animationName"); return self.$alias_native("elapsed", "elapsedTime"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/audio_processing"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'AudioProcessing'); var $nesting = [self].concat($parent_nesting), $AudioProcessing_supported$ques$1, $AudioProcessing_construct$5; Opal.defs(self, '$supported?', $AudioProcessing_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.AudioProcessing") }, $AudioProcessing_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_time$eq$2, $Definition_input$eq$3, $Definition_output$eq$4; self.$$prototype["native"] = nil; Opal.def(self, '$time=', $Definition_time$eq$2 = function(value) { var self = this; return self["native"].playbackTime = value }, $Definition_time$eq$2.$$arity = 1); Opal.def(self, '$input=', $Definition_input$eq$3 = function(value) { var self = this; return self["native"].inputBuffer = value }, $Definition_input$eq$3.$$arity = 1); return (Opal.def(self, '$output=', $Definition_output$eq$4 = function(value) { var self = this; return self["native"].outputBuffer = value }, $Definition_output$eq$4.$$arity = 1), nil) && 'output='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $AudioProcessing_construct$5 = function $$construct(name, desc) { var self = this; return new AudioProcessingEvent(name, desc) }, $AudioProcessing_construct$5.$$arity = 2)}}; self.$alias_native("time", "playbackTime"); self.$alias_native("input", "inputBuffer"); return self.$alias_native("output", "outputBuffer"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/before_unload"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'BeforeUnload'); var $nesting = [self].concat($parent_nesting), $BeforeUnload_supported$ques$1, $BeforeUnload_construct$2; Opal.defs(self, '$supported?', $BeforeUnload_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.BeforeUnload") }, $BeforeUnload_supported$ques$1.$$arity = 0); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { return (Opal.defs(self, '$construct', $BeforeUnload_construct$2 = function $$construct(name, desc) { var self = this; return new BeforeUnloadEvent(name, desc) }, $BeforeUnload_construct$2.$$arity = 2), nil) && 'construct' } else { return nil } } else { return nil }; })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/clipboard"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Clipboard'); var $nesting = [self].concat($parent_nesting), $Clipboard_supported$ques$1, $Clipboard_construct$4; Opal.defs(self, '$supported?', $Clipboard_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Clipboard") }, $Clipboard_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_data$eq$2, $Definition_type$eq$3; self.$$prototype["native"] = nil; Opal.def(self, '$data=', $Definition_data$eq$2 = function(value) { var self = this; return self["native"].data = value }, $Definition_data$eq$2.$$arity = 1); return (Opal.def(self, '$type=', $Definition_type$eq$3 = function(value) { var self = this; return self["native"].dataType = value }, $Definition_type$eq$3.$$arity = 1), nil) && 'type='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Clipboard_construct$4 = function $$construct(name, desc) { var self = this; return new ClipboardEvent(name, desc) }, $Clipboard_construct$4.$$arity = 2)}}; self.$alias_native("data"); return self.$alias_native("type", "dataType"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/device_light"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'DeviceLight'); var $nesting = [self].concat($parent_nesting), $DeviceLight_supported$ques$1, $DeviceLight_construct$3; Opal.defs(self, '$supported?', $DeviceLight_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.DeviceLight") }, $DeviceLight_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_value$eq$2; self.$$prototype["native"] = nil; return (Opal.def(self, '$value=', $Definition_value$eq$2 = function(value) { var self = this; return self["native"].value = value }, $Definition_value$eq$2.$$arity = 1), nil) && 'value=' })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $DeviceLight_construct$3 = function $$construct(name, desc) { var self = this; return new DeviceLightEvent(name, desc) }, $DeviceLight_construct$3.$$arity = 2)}}; return self.$alias_native("value"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/device_motion"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$new', '$to_n', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'DeviceMotion'); var $nesting = [self].concat($parent_nesting), $DeviceMotion_supported$ques$1, $DeviceMotion_construct$6, $DeviceMotion_construct$7; Opal.defs(self, '$supported?', $DeviceMotion_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.DeviceMotion") }, $DeviceMotion_supported$ques$1.$$arity = 0); Opal.const_set($nesting[0], 'Acceleration', $$($nesting, 'Struct').$new("x", "y", "z")); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_acceleration$eq$2, $Definition_acceleration_with_gravity$eq$3, $Definition_rotation$eq$4, $Definition_interval$eq$5; self.$$prototype["native"] = nil; Opal.def(self, '$acceleration=', $Definition_acceleration$eq$2 = function(value) { var self = this; return self["native"].acceleration = value.$to_n() }, $Definition_acceleration$eq$2.$$arity = 1); Opal.def(self, '$acceleration_with_gravity=', $Definition_acceleration_with_gravity$eq$3 = function(value) { var self = this; return self["native"].accelerationIncludingGravity = value.$to_n() }, $Definition_acceleration_with_gravity$eq$3.$$arity = 1); Opal.def(self, '$rotation=', $Definition_rotation$eq$4 = function(value) { var self = this; return self["native"].rotationRate = value }, $Definition_rotation$eq$4.$$arity = 1); return (Opal.def(self, '$interval=', $Definition_interval$eq$5 = function(value) { var self = this; return self["native"].interval = value }, $Definition_interval$eq$5.$$arity = 1), nil) && 'interval='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $DeviceMotion_construct$6 = function $$construct(name, desc) { var self = this; return new DeviceMotionEvent(name, desc) }, $DeviceMotion_construct$6.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $DeviceMotion_construct$7 = function $$construct(name, desc) { var self = this; var event = document.createEvent("DeviceMotionEvent"); event.initDeviceMotionEvent(name, desc.bubbles, desc.cancelable, desc.acceleration, desc.accelerationIncludingGravity, desc.rotationRate, desc.interval); return event; }, $DeviceMotion_construct$7.$$arity = 2)}}; self.$alias_native("acceleration"); self.$alias_native("acceleration_with_gravity", "accelerationIncludingGravity"); self.$alias_native("rotation", "rotationRate"); return self.$alias_native("interval"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/device_orientation"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'DeviceOrientation'); var $nesting = [self].concat($parent_nesting), $DeviceOrientation_supported$ques$1, $DeviceOrientation_construct$6, $DeviceOrientation_construct$7; Opal.defs(self, '$supported?', $DeviceOrientation_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.DeviceOrientation") }, $DeviceOrientation_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_absolute$eq$2, $Definition_alpha$eq$3, $Definition_beta$eq$4, $Definition_gamma$eq$5; self.$$prototype["native"] = nil; Opal.def(self, '$absolute=', $Definition_absolute$eq$2 = function(value) { var self = this; return self["native"].absolute = value }, $Definition_absolute$eq$2.$$arity = 1); Opal.def(self, '$alpha=', $Definition_alpha$eq$3 = function(value) { var self = this; return self["native"].alpha = value }, $Definition_alpha$eq$3.$$arity = 1); Opal.def(self, '$beta=', $Definition_beta$eq$4 = function(value) { var self = this; return self["native"].beta = value }, $Definition_beta$eq$4.$$arity = 1); return (Opal.def(self, '$gamma=', $Definition_gamma$eq$5 = function(value) { var self = this; return self["native"].gamma = value }, $Definition_gamma$eq$5.$$arity = 1), nil) && 'gamma='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $DeviceOrientation_construct$6 = function $$construct(name, desc) { var self = this; return new DeviceOrientationEvent(name, desc) }, $DeviceOrientation_construct$6.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $DeviceOrientation_construct$7 = function $$construct(name, desc) { var self = this; var event = document.createEvent("DeviceOrientationEvent"); event.initDeviceOrientationEvent(name, desc.bubbles, desc.cancelable, desc.alpha, desc.beta, desc.gamma, desc.absolute); return event; }, $DeviceOrientation_construct$7.$$arity = 2)}}; self.$alias_native("absolute"); self.$alias_native("alpha"); self.$alias_native("beta"); return self.$alias_native("gamma"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/device_proximity"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'DeviceProximity'); var $nesting = [self].concat($parent_nesting), $DeviceProximity_supported$ques$1, $DeviceProximity_construct$5; Opal.defs(self, '$supported?', $DeviceProximity_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.DeviceProximity") }, $DeviceProximity_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_value$eq$2, $Definition_min$eq$3, $Definition_max$eq$4; self.$$prototype["native"] = nil; Opal.def(self, '$value=', $Definition_value$eq$2 = function(value) { var self = this; return self["native"].value = value }, $Definition_value$eq$2.$$arity = 1); Opal.def(self, '$min=', $Definition_min$eq$3 = function(value) { var self = this; return self["native"].min = value }, $Definition_min$eq$3.$$arity = 1); return (Opal.def(self, '$max=', $Definition_max$eq$4 = function(value) { var self = this; return self["native"].max = value }, $Definition_max$eq$4.$$arity = 1), nil) && 'max='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $DeviceProximity_construct$5 = function $$construct(name, desc) { var self = this; return new DeviceProximityEvent(name, desc) }, $DeviceProximity_construct$5.$$arity = 2)}}; self.$alias_native("value"); self.$alias_native("min"); return self.$alias_native("max"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/drag"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$include', '$new', '$convert', '$elem', '$supported?', '$alias_native', '$x', '$screen', '$y', '$DOM', '$raise']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Drag'); var $nesting = [self].concat($parent_nesting), $Drag_supported$ques$1, $Drag_construct$14, $Drag_construct$15, $Drag_client$16, $Drag_screen$17, $Drag_x$18, $Drag_y$19, $Drag_related$20, $Drag_transfer$21; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $Drag_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Drag") }, $Drag_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_alt$excl$6, $Definition_ctrl$excl$7, $Definition_meta$excl$8, $Definition_button$eq$9, $Definition_client$10, $Definition_screen$11, $Definition_related$eq$12, $Definition_transfer$eq$13; self.$$prototype["native"] = nil; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Client'); var $nesting = [self].concat($parent_nesting), $Client_x$eq$2, $Client_y$eq$3; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Client_x$eq$2 = function(value) { var self = this; return self["native"].clientX = value }, $Client_x$eq$2.$$arity = 1); return (Opal.def(self, '$y=', $Client_y$eq$3 = function(value) { var self = this; return self["native"].clientY = value }, $Client_y$eq$3.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Screen'); var $nesting = [self].concat($parent_nesting), $Screen_x$eq$4, $Screen_y$eq$5; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$x=', $Screen_x$eq$4 = function(value) { var self = this; return self["native"].screenX = value }, $Screen_x$eq$4.$$arity = 1); return (Opal.def(self, '$y=', $Screen_y$eq$5 = function(value) { var self = this; return self["native"].screenY = value }, $Screen_y$eq$5.$$arity = 1), nil) && 'y='; })($nesting[0], null, $nesting); Opal.def(self, '$alt!', $Definition_alt$excl$6 = function() { var self = this; return self["native"].altKey = true }, $Definition_alt$excl$6.$$arity = 0); Opal.def(self, '$ctrl!', $Definition_ctrl$excl$7 = function() { var self = this; return self["native"].ctrlKey = true }, $Definition_ctrl$excl$7.$$arity = 0); Opal.def(self, '$meta!', $Definition_meta$excl$8 = function() { var self = this; return self["native"].metaKey = true }, $Definition_meta$excl$8.$$arity = 0); Opal.def(self, '$button=', $Definition_button$eq$9 = function(value) { var self = this; return self["native"].button = value }, $Definition_button$eq$9.$$arity = 1); Opal.def(self, '$client', $Definition_client$10 = function $$client() { var self = this; return $$($nesting, 'Client').$new(self["native"]) }, $Definition_client$10.$$arity = 0); Opal.def(self, '$screen', $Definition_screen$11 = function $$screen() { var self = this; return $$($nesting, 'Screen').$new(self["native"]) }, $Definition_screen$11.$$arity = 0); Opal.def(self, '$related=', $Definition_related$eq$12 = function(elem) { var self = this; return self["native"].relatedTarget = $$($nesting, 'Native').$convert(elem) }, $Definition_related$eq$12.$$arity = 1); return (Opal.def(self, '$transfer=', $Definition_transfer$eq$13 = function(value) { var self = this; return self["native"].dataTransfer = $$($nesting, 'Native').$convert(self.$elem()) }, $Definition_transfer$eq$13.$$arity = 1), nil) && 'transfer='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Drag_construct$14 = function $$construct(name, desc) { var self = this; return new DragEvent(name, desc) }, $Drag_construct$14.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Drag_construct$15 = function $$construct(name, desc) { var self = this; var event = document.createEvent("DragEvent"); event.initDragEvent(name, desc.bubbles, desc.cancelable, desc.view || window, 0, desc.screenX || 0, desc.screenY || 0, desc.clientX || 0, desc.clientY || 0, desc.ctrlKey, desc.altKey, desc.shiftKey, desc.metaKey, desc.button || 0, desc.relatedTarget, desc.dataTransfer); return event; }, $Drag_construct$15.$$arity = 2)}}; self.$alias_native("alt?", "altKey"); self.$alias_native("ctrl?", "ctrlKey"); self.$alias_native("meta?", "metaKey"); self.$alias_native("shift?", "shiftKey"); self.$alias_native("button"); Opal.def(self, '$client', $Drag_client$16 = function $$client() { var self = this; return $$($nesting, 'Position').$new(self["native"].clientX, self["native"].clientY) }, $Drag_client$16.$$arity = 0); Opal.def(self, '$screen', $Drag_screen$17 = function $$screen() { var self = this; if ($truthy((typeof(self["native"].screenX) !== "undefined"))) { return $$($nesting, 'Position').$new(self["native"].screenX, self["native"].screenY) } else { return nil } }, $Drag_screen$17.$$arity = 0); Opal.def(self, '$x', $Drag_x$18 = function $$x() { var self = this; return self.$screen().$x() }, $Drag_x$18.$$arity = 0); Opal.def(self, '$y', $Drag_y$19 = function $$y() { var self = this; return self.$screen().$y() }, $Drag_y$19.$$arity = 0); Opal.def(self, '$related', $Drag_related$20 = function $$related() { var self = this; return self.$DOM(self["native"].relatedTarget) }, $Drag_related$20.$$arity = 0); return (Opal.def(self, '$transfer', $Drag_transfer$21 = function $$transfer() { var self = this; return self.$raise($$($nesting, 'NotImplementedError')) }, $Drag_transfer$21.$$arity = 0), nil) && 'transfer'; })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/gamepad"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Gamepad'); var $nesting = [self].concat($parent_nesting), $Gamepad_supported$ques$1, $Gamepad_construct$7, $Gamepad_id$8, $Gamepad_index$9, $Gamepad_at$10, $Gamepad_axes$11, $Gamepad_buttons$12; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $Gamepad_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Gamepad") }, $Gamepad_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_id$eq$2, $Definition_index$eq$3, $Definition_at$eq$4, $Definition_axes$eq$5, $Definition_buttons$eq$6; self.$$prototype["native"] = nil; Opal.def(self, '$id=', $Definition_id$eq$2 = function(value) { var self = this; return self["native"].id = value }, $Definition_id$eq$2.$$arity = 1); Opal.def(self, '$index=', $Definition_index$eq$3 = function(value) { var self = this; return self["native"].index = value }, $Definition_index$eq$3.$$arity = 1); Opal.def(self, '$at=', $Definition_at$eq$4 = function(value) { var self = this; return self["native"].timestamp = value }, $Definition_at$eq$4.$$arity = 1); Opal.def(self, '$axes=', $Definition_axes$eq$5 = function(value) { var self = this; return self["native"].axes = value }, $Definition_axes$eq$5.$$arity = 1); return (Opal.def(self, '$buttons=', $Definition_buttons$eq$6 = function(value) { var self = this; return self["native"].buttons = value }, $Definition_buttons$eq$6.$$arity = 1), nil) && 'buttons='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Gamepad_construct$7 = function $$construct(name, desc) { var self = this; new GamepadEvent(name, { bubbles: desc.bubbles, cancelable: desc.cancelable, gamepad: desc }) }, $Gamepad_construct$7.$$arity = 2)}}; Opal.def(self, '$id', $Gamepad_id$8 = function $$id() { var self = this; return self["native"].gamepad.id }, $Gamepad_id$8.$$arity = 0); Opal.def(self, '$index', $Gamepad_index$9 = function $$index() { var self = this; return self["native"].gamepad.index }, $Gamepad_index$9.$$arity = 0); Opal.def(self, '$at', $Gamepad_at$10 = function $$at() { var self = this; return self["native"].gamepad.timestamp }, $Gamepad_at$10.$$arity = 0); Opal.def(self, '$axes', $Gamepad_axes$11 = function $$axes() { var self = this; return self["native"].gamepad.axes }, $Gamepad_axes$11.$$arity = 0); return (Opal.def(self, '$buttons', $Gamepad_buttons$12 = function $$buttons() { var self = this; return self["native"].gamepad.buttons }, $Gamepad_buttons$12.$$arity = 0), nil) && 'buttons'; })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/hash_change"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'HashChange'); var $nesting = [self].concat($parent_nesting), $HashChange_supported$ques$1, $HashChange_construct$4; Opal.defs(self, '$supported?', $HashChange_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.HashChange") }, $HashChange_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_old$eq$2, $Definition_new$eq$3; self.$$prototype["native"] = nil; Opal.def(self, '$old=', $Definition_old$eq$2 = function(value) { var self = this; return self["native"].oldURL = value }, $Definition_old$eq$2.$$arity = 1); return (Opal.def(self, '$new=', $Definition_new$eq$3 = function(value) { var self = this; return self["native"].newURL = value }, $Definition_new$eq$3.$$arity = 1), nil) && 'new='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $HashChange_construct$4 = function $$construct(name, desc) { var self = this; return new HashChangeEvent(name, desc) }, $HashChange_construct$4.$$arity = 2)}}; self.$alias_native("old", "oldURL"); return self.$alias_native("new", "newURL"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/progress"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Progress'); var $nesting = [self].concat($parent_nesting), $Progress_supported$ques$1, $Progress_construct$5, $Progress_construct$6; Opal.defs(self, '$supported?', $Progress_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Progress") }, $Progress_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_computable$eq$2, $Definition_loaded$eq$3, $Definition_total$eq$4; self.$$prototype["native"] = nil; Opal.def(self, '$computable=', $Definition_computable$eq$2 = function(value) { var self = this; return self["native"].computableLength = value }, $Definition_computable$eq$2.$$arity = 1); Opal.def(self, '$loaded=', $Definition_loaded$eq$3 = function(value) { var self = this; return self["native"].loaded = value }, $Definition_loaded$eq$3.$$arity = 1); return (Opal.def(self, '$total=', $Definition_total$eq$4 = function(value) { var self = this; return self["native"].total = value }, $Definition_total$eq$4.$$arity = 1), nil) && 'total='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Progress_construct$5 = function $$construct(name, desc) { var self = this; return new ProgressEvent(name, desc) }, $Progress_construct$5.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Progress_construct$6 = function $$construct(name, desc) { var self = this; var event = document.createEvent("ProgressEvent"); event.initProgressEvent(name, desc.bubbles, desc.cancelable, desc.computable, desc.loaded, desc.total); return event; }, $Progress_construct$6.$$arity = 2)}}; self.$alias_native("computable?", "computableLength"); self.$alias_native("loaded"); return self.$alias_native("total"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/page_transition"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'PageTransition'); var $nesting = [self].concat($parent_nesting), $PageTransition_supported$ques$1, $PageTransition_construct$3; Opal.defs(self, '$supported?', $PageTransition_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.PageTransition") }, $PageTransition_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_persisted$eq$2; self.$$prototype["native"] = nil; return (Opal.def(self, '$persisted=', $Definition_persisted$eq$2 = function(value) { var self = this; return self["native"].persisted = value }, $Definition_persisted$eq$2.$$arity = 1), nil) && 'persisted=' })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.PageTransition"))) { Opal.defs(self, '$construct', $PageTransition_construct$3 = function $$construct(name, desc) { var self = this; return new PageTransitionEvent(name, desc); }, $PageTransition_construct$3.$$arity = 2)}}; return self.$alias_native("persisted?", "persisted"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/pop_state"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'PopState'); var $nesting = [self].concat($parent_nesting), $PopState_supported$ques$1, $PopState_construct$3, $PopState_construct$4; Opal.defs(self, '$supported?', $PopState_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.PopState") }, $PopState_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_state$eq$2; self.$$prototype["native"] = nil; return (Opal.def(self, '$state=', $Definition_state$eq$2 = function(value) { var self = this; return self["native"].state = value }, $Definition_state$eq$2.$$arity = 1), nil) && 'state=' })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $PopState_construct$3 = function $$construct(name, desc) { var self = this; return new PopStateEvent(name, desc) }, $PopState_construct$3.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $PopState_construct$4 = function $$construct(name, desc) { var self = this; var event = document.createEvent('PopStateEvent'); event.initPopStateEvent(name, desc.bubbles, desc.cancelable, desc.state); return event; }, $PopState_construct$4.$$arity = 2)}}; return self.$alias_native("state"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/storage"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Storage'); var $nesting = [self].concat($parent_nesting), $Storage_supported$ques$1, $Storage_construct$7; Opal.defs(self, '$supported?', $Storage_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Storage") }, $Storage_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_key$eq$2, $Definition_new$eq$3, $Definition_old$eq$4, $Definition_area$eq$5, $Definition_url$eq$6; self.$$prototype["native"] = nil; Opal.def(self, '$key=', $Definition_key$eq$2 = function(value) { var self = this; return self["native"].key = value }, $Definition_key$eq$2.$$arity = 1); Opal.def(self, '$new=', $Definition_new$eq$3 = function(value) { var self = this; return self["native"].newValue = value }, $Definition_new$eq$3.$$arity = 1); Opal.def(self, '$old=', $Definition_old$eq$4 = function(value) { var self = this; return self["native"].oldValue = value }, $Definition_old$eq$4.$$arity = 1); Opal.def(self, '$area=', $Definition_area$eq$5 = function(value) { var self = this; return self["native"].storageArea = value }, $Definition_area$eq$5.$$arity = 1); return (Opal.def(self, '$url=', $Definition_url$eq$6 = function(value) { var self = this; return self["native"].url = value }, $Definition_url$eq$6.$$arity = 1), nil) && 'url='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Storage_construct$7 = function $$construct(name, desc) { var self = this; return new StorageEvent(name, desc) }, $Storage_construct$7.$$arity = 2)}}; self.$alias_native("key"); self.$alias_native("new", "newValue"); self.$alias_native("old", "oldValue"); self.$alias_native("area", "storageArea"); return self.$alias_native("url"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/touch"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native', '$==', '$downcase', '$name']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Touch'); var $nesting = [self].concat($parent_nesting), $Touch_supported$ques$1, $Touch_construct$6, $Touch_cancel$ques$7, $Touch_end$ques$8, $Touch_leave$ques$9, $Touch_move$ques$10, $Touch_start$ques$11; Opal.defs(self, '$supported?', $Touch_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Touch") }, $Touch_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_alt$excl$2, $Definition_ctrl$excl$3, $Definition_meta$excl$4, $Definition_shift$excl$5; self.$$prototype["native"] = nil; Opal.def(self, '$alt!', $Definition_alt$excl$2 = function() { var self = this; return self["native"].altKey = true }, $Definition_alt$excl$2.$$arity = 0); Opal.def(self, '$ctrl!', $Definition_ctrl$excl$3 = function() { var self = this; return self["native"].ctrlKey = true }, $Definition_ctrl$excl$3.$$arity = 0); Opal.def(self, '$meta!', $Definition_meta$excl$4 = function() { var self = this; return self["native"].metaKey = true }, $Definition_meta$excl$4.$$arity = 0); return (Opal.def(self, '$shift!', $Definition_shift$excl$5 = function() { var self = this; return self["native"].shiftKey = true }, $Definition_shift$excl$5.$$arity = 0), nil) && 'shift!'; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Touch_construct$6 = function $$construct(name, desc) { var self = this; return new TouchEvent(name, desc) }, $Touch_construct$6.$$arity = 2)}}; self.$alias_native("alt?", "altKey"); self.$alias_native("ctrl?", "ctrlKey"); self.$alias_native("meta?", "metaKey"); self.$alias_native("shift?", "shiftKey"); Opal.def(self, '$cancel?', $Touch_cancel$ques$7 = function() { var self = this; return self.$name().$downcase()['$==']("touchcancel") }, $Touch_cancel$ques$7.$$arity = 0); Opal.def(self, '$end?', $Touch_end$ques$8 = function() { var self = this; return self.$name().$downcase()['$==']("touchend") }, $Touch_end$ques$8.$$arity = 0); Opal.def(self, '$leave?', $Touch_leave$ques$9 = function() { var self = this; return self.$name().$downcase()['$==']("touchleave") }, $Touch_leave$ques$9.$$arity = 0); Opal.def(self, '$move?', $Touch_move$ques$10 = function() { var self = this; return self.$name().$downcase()['$==']("touchmove") }, $Touch_move$ques$10.$$arity = 0); return (Opal.def(self, '$start?', $Touch_start$ques$11 = function() { var self = this; return self.$name().$downcase()['$==']("touchstart") }, $Touch_start$ques$11.$$arity = 0), nil) && 'start?'; })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/sensor"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Sensor'); var $nesting = [self].concat($parent_nesting), $Sensor_supported$ques$1, $Sensor_construct$2; Opal.defs(self, '$supported?', $Sensor_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Sensor") }, $Sensor_supported$ques$1.$$arity = 0); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { return (Opal.defs(self, '$construct', $Sensor_construct$2 = function $$construct(name, desc) { var self = this; return new SensorEvent(name, desc) }, $Sensor_construct$2.$$arity = 2), nil) && 'construct' } else { return nil } } else { return nil }; })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["ostruct"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $hash2 = Opal.hash2, $truthy = Opal.truthy, $send = Opal.send, $range = Opal.range; Opal.add_stubs(['$each_pair', '$new_ostruct_member', '$[]=', '$-', '$[]', '$to_sym', '$>', '$length', '$raise', '$new', '$end_with?', '$!=', '$enum_for', '$is_a?', '$==', '$instance_variable_get', '$===', '$eql?', '$dup', '$to_n', '$hash', '$attr_reader', '$__send__', '$singleton_class', '$delete', '$respond_to?', '$define_singleton_method', '$__id__', '$class', '$any?', '$+', '$join', '$map', '$inspect']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'OpenStruct'); var $nesting = [self].concat($parent_nesting), $OpenStruct_initialize$1, $OpenStruct_$$$3, $OpenStruct_$$$eq$4, $OpenStruct_method_missing$5, $OpenStruct_each_pair$6, $OpenStruct_$eq_eq$8, $OpenStruct_$eq_eq_eq$9, $OpenStruct_eql$ques$10, $OpenStruct_to_h$11, $OpenStruct_to_n$12, $OpenStruct_hash$13, $OpenStruct_delete_field$14, $OpenStruct_new_ostruct_member$15, $OpenStruct_inspect$18; self.$$prototype.table = nil; Opal.def(self, '$initialize', $OpenStruct_initialize$1 = function $$initialize(hash) { var $$2, self = this; if (hash == null) { hash = nil; }; self.table = $hash2([], {}); if ($truthy(hash)) { return $send(hash, 'each_pair', [], ($$2 = function(key, value){var self = $$2.$$s || this, $writer = nil; if (self.table == null) self.table = nil; if (key == null) { key = nil; }; if (value == null) { value = nil; }; $writer = [self.$new_ostruct_member(key), value]; $send(self.table, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$2.$$s = self, $$2.$$arity = 2, $$2)) } else { return nil }; }, $OpenStruct_initialize$1.$$arity = -1); Opal.def(self, '$[]', $OpenStruct_$$$3 = function(name) { var self = this; return self.table['$[]'](name.$to_sym()) }, $OpenStruct_$$$3.$$arity = 1); Opal.def(self, '$[]=', $OpenStruct_$$$eq$4 = function(name, value) { var self = this, $writer = nil; $writer = [self.$new_ostruct_member(name), value]; $send(self.table, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; }, $OpenStruct_$$$eq$4.$$arity = 2); Opal.def(self, '$method_missing', $OpenStruct_method_missing$5 = function $$method_missing(name, $a) { var $post_args, args, self = this, $writer = nil; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy($rb_gt(args.$length(), 2))) { self.$raise($$($nesting, 'NoMethodError').$new("" + "undefined method `" + (name) + "' for #", name))}; if ($truthy(name['$end_with?']("="))) { if ($truthy(args.$length()['$!='](1))) { self.$raise($$($nesting, 'ArgumentError'), "wrong number of arguments (0 for 1)")}; $writer = [self.$new_ostruct_member(name['$[]']($range(0, -2, false))), args['$[]'](0)]; $send(self.table, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];; } else { return self.table['$[]'](name.$to_sym()) }; }, $OpenStruct_method_missing$5.$$arity = -2); Opal.def(self, '$each_pair', $OpenStruct_each_pair$6 = function $$each_pair() { var $$7, $iter = $OpenStruct_each_pair$6.$$p, $yield = $iter || nil, self = this; if ($iter) $OpenStruct_each_pair$6.$$p = null; if (($yield !== nil)) { } else { return self.$enum_for("each_pair") }; return $send(self.table, 'each_pair', [], ($$7 = function(pair){var self = $$7.$$s || this; if (pair == null) { pair = nil; }; return Opal.yield1($yield, pair);;}, $$7.$$s = self, $$7.$$arity = 1, $$7)); }, $OpenStruct_each_pair$6.$$arity = 0); Opal.def(self, '$==', $OpenStruct_$eq_eq$8 = function(other) { var self = this; if ($truthy(other['$is_a?']($$($nesting, 'OpenStruct')))) { } else { return false }; return self.table['$=='](other.$instance_variable_get("@table")); }, $OpenStruct_$eq_eq$8.$$arity = 1); Opal.def(self, '$===', $OpenStruct_$eq_eq_eq$9 = function(other) { var self = this; if ($truthy(other['$is_a?']($$($nesting, 'OpenStruct')))) { } else { return false }; return self.table['$==='](other.$instance_variable_get("@table")); }, $OpenStruct_$eq_eq_eq$9.$$arity = 1); Opal.def(self, '$eql?', $OpenStruct_eql$ques$10 = function(other) { var self = this; if ($truthy(other['$is_a?']($$($nesting, 'OpenStruct')))) { } else { return false }; return self.table['$eql?'](other.$instance_variable_get("@table")); }, $OpenStruct_eql$ques$10.$$arity = 1); Opal.def(self, '$to_h', $OpenStruct_to_h$11 = function $$to_h() { var self = this; return self.table.$dup() }, $OpenStruct_to_h$11.$$arity = 0); Opal.def(self, '$to_n', $OpenStruct_to_n$12 = function $$to_n() { var self = this; return self.table.$to_n() }, $OpenStruct_to_n$12.$$arity = 0); Opal.def(self, '$hash', $OpenStruct_hash$13 = function $$hash() { var self = this; return self.table.$hash() }, $OpenStruct_hash$13.$$arity = 0); self.$attr_reader("table"); Opal.def(self, '$delete_field', $OpenStruct_delete_field$14 = function $$delete_field(name) { var self = this, sym = nil; sym = name.$to_sym(); try { self.$singleton_class().$__send__("remove_method", sym, "" + (sym) + "=") } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'NameError')])) { try { nil } finally { Opal.pop_exception() } } else { throw $err; } };; return self.table.$delete(sym); }, $OpenStruct_delete_field$14.$$arity = 1); Opal.def(self, '$new_ostruct_member', $OpenStruct_new_ostruct_member$15 = function $$new_ostruct_member(name) { var $$16, $$17, self = this; name = name.$to_sym(); if ($truthy(self['$respond_to?'](name))) { } else { $send(self, 'define_singleton_method', [name], ($$16 = function(){var self = $$16.$$s || this; if (self.table == null) self.table = nil; return self.table['$[]'](name)}, $$16.$$s = self, $$16.$$arity = 0, $$16)); $send(self, 'define_singleton_method', ["" + (name) + "="], ($$17 = function(x){var self = $$17.$$s || this, $writer = nil; if (self.table == null) self.table = nil; if (x == null) { x = nil; }; $writer = [name, x]; $send(self.table, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$17.$$s = self, $$17.$$arity = 1, $$17)); }; return name; }, $OpenStruct_new_ostruct_member$15.$$arity = 1); var ostruct_ids;; Opal.def(self, '$inspect', $OpenStruct_inspect$18 = function $$inspect() { var $$19, self = this, result = nil; var top = (ostruct_ids === undefined), ostruct_id = self.$__id__(); ; return (function() { try { result = "" + "#<" + (self.$class()); if (top) { ostruct_ids = {}; } if (ostruct_ids.hasOwnProperty(ostruct_id)) { return result + ' ...>'; } ostruct_ids[ostruct_id] = true; ; if ($truthy(self.table['$any?']())) { result = $rb_plus(result, " ")}; result = $rb_plus(result, $send(self.$each_pair(), 'map', [], ($$19 = function(name, value){var self = $$19.$$s || this; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return "" + (name) + "=" + (value.$inspect());}, $$19.$$s = self, $$19.$$arity = 2, $$19)).$join(", ")); result = $rb_plus(result, ">"); return result; } finally { if (top) { ostruct_ids = undefined; } }; })();; }, $OpenStruct_inspect$18.$$arity = 0); return Opal.alias(self, "to_s", "inspect"); })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/custom"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $range = Opal.range, $send = Opal.send; Opal.add_stubs(['$require', '$supports?', '$end_with?', '$[]', '$to_n', '$merge!', '$Native', '$new', '$has_key?']); self.$require("ostruct"); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Custom'); var $nesting = [self].concat($parent_nesting), $Custom_supported$ques$1, $Custom_construct$3, $Custom_construct$4, $Custom_construct$5, $Custom_construct$6, $Custom_initialize$7, $Custom_method_missing$8; self.$$prototype.detail = nil; Opal.defs(self, '$supported?', $Custom_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Custom") }, $Custom_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_method_missing$2; self.$$prototype["native"] = nil; return (Opal.def(self, '$method_missing', $Definition_method_missing$2 = function $$method_missing(name, value) { var self = this; if ($truthy(name['$end_with?']("="))) { return self["native"][name['$[]']($range(0, -2, false))] = value } else { return nil } }, $Definition_method_missing$2.$$arity = 2), nil) && 'method_missing' })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Custom_construct$3 = function $$construct(name, desc) { var self = this; new CustomEvent(name, { bubbles: desc.bubbles, cancelable: desc.cancelable, detail: desc }) }, $Custom_construct$3.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Custom_construct$4 = function $$construct(name, desc) { var self = this; var event = document.createEvent("CustomEvent"); event.initCustomEvent(name, desc.bubbles, desc.cancelable, desc); return event; }, $Custom_construct$4.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.createObject"))) { Opal.defs(self, '$construct', $Custom_construct$5 = function $$construct(name, desc) { var self = this; return self.$Native(document.createEventObject())['$merge!']({ type: name, bubbles: desc.bubbles, cancelable: desc.cancelable, detail: desc }).$to_n() }, $Custom_construct$5.$$arity = 2) } else { Opal.defs(self, '$construct', $Custom_construct$6 = function $$construct(name, desc) { var self = this; return self.$Native(desc)['$merge!']({ type: name, bubbles: desc.bubbles, cancelable: desc.cancelable, detail: desc }).$to_n() }, $Custom_construct$6.$$arity = 2) }; Opal.def(self, '$initialize', $Custom_initialize$7 = function $$initialize(event, callback) { var $iter = $Custom_initialize$7.$$p, $yield = $iter || nil, self = this; if ($iter) $Custom_initialize$7.$$p = null; if (callback == null) { callback = nil; }; $send(self, Opal.find_super_dispatcher(self, 'initialize', $Custom_initialize$7, false), [event, callback], null); return (self.detail = $$($nesting, 'Hash').$new(event.detail)); }, $Custom_initialize$7.$$arity = -2); return (Opal.def(self, '$method_missing', $Custom_method_missing$8 = function $$method_missing(id, $a) { var $post_args, $iter = $Custom_method_missing$8.$$p, $yield = $iter || nil, self = this, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Custom_method_missing$8.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } $post_args = Opal.slice.call(arguments, 1, arguments.length); ; if ($truthy(self.detail['$has_key?'](id))) { return self.detail['$[]'](id)}; return $send(self, Opal.find_super_dispatcher(self, 'method_missing', $Custom_method_missing$8, false), $zuper, $iter); }, $Custom_method_missing$8.$$arity = -2), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["buffer/array"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars, $send = Opal.send, $truthy = Opal.truthy; Opal.add_stubs(['$include', '$[]', '$name_for', '$attr_reader', '$==', '$for', '$to_n', '$enum_for']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Buffer'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Array'); var $nesting = [self].concat($parent_nesting), $Array_for$1, $Array_initialize$2, $Array_bits$3, $Array_$$$4, $Array_$$$eq$5, $Array_bytesize$6, $Array_each$7, $Array_length$8, $Array_merge$excl$9; self.$$prototype["native"] = nil; self.$include($$$($$($nesting, 'Native'), 'Wrapper')); Opal.defs(self, '$for', $Array_for$1 = function(bits, type) { var self = this; if ($gvars.$ == null) $gvars.$ = nil; return $gvars.$['$[]']("" + ($$($nesting, 'Buffer').$name_for(bits, type)) + "Array") }, $Array_for$1.$$arity = 2); self.$include($$($nesting, 'Enumerable')); self.$attr_reader("buffer", "type"); Opal.def(self, '$initialize', $Array_initialize$2 = function $$initialize(buffer, bits, type) { var $iter = $Array_initialize$2.$$p, $yield = $iter || nil, self = this; if ($iter) $Array_initialize$2.$$p = null; if (bits == null) { bits = nil; }; if (type == null) { type = nil; }; if ($$($nesting, 'Native')['$=='](buffer)) { $send(self, Opal.find_super_dispatcher(self, 'initialize', $Array_initialize$2, false), [buffer], null) } else { var klass = $$($nesting, 'Array').$for(bits, type); $send(self, Opal.find_super_dispatcher(self, 'initialize', $Array_initialize$2, false), [new klass(buffer.$to_n())], null) }; self.buffer = buffer; return (self.type = type); }, $Array_initialize$2.$$arity = -2); Opal.def(self, '$bits', $Array_bits$3 = function $$bits() { var self = this; return self["native"].BYTES_PER_ELEMENT * 8 }, $Array_bits$3.$$arity = 0); Opal.def(self, '$[]', $Array_$$$4 = function(index, offset) { var self = this; if (offset == null) { offset = nil; }; if ($truthy(offset)) { return self["native"].subarray(index, offset) } else { return self["native"][index] }; }, $Array_$$$4.$$arity = -2); Opal.def(self, '$[]=', $Array_$$$eq$5 = function(index, value) { var self = this; return self["native"][index] = value }, $Array_$$$eq$5.$$arity = 2); Opal.def(self, '$bytesize', $Array_bytesize$6 = function $$bytesize() { var self = this; return self["native"].byteLength }, $Array_bytesize$6.$$arity = 0); Opal.def(self, '$each', $Array_each$7 = function $$each() { var $iter = $Array_each$7.$$p, $yield = $iter || nil, self = this; if ($iter) $Array_each$7.$$p = null; if (($yield !== nil)) { } else { return self.$enum_for("each") }; for (var i = 0, length = self["native"].length; i < length; i++) { Opal.yield1($yield, self["native"][i]) } ; return self; }, $Array_each$7.$$arity = 0); Opal.def(self, '$length', $Array_length$8 = function $$length() { var self = this; return self["native"].length }, $Array_length$8.$$arity = 0); Opal.def(self, '$merge!', $Array_merge$excl$9 = function(other, offset) { var self = this; ; return self["native"].set(other.$to_n(), offset); }, $Array_merge$excl$9.$$arity = -2); return Opal.alias(self, "size", "length"); })($nesting[0], null, $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["buffer/view"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$include', '$!', '$nil?', '$[]', '$attr_reader', '$native?', '$to_n', '$name_for']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Buffer'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'View'); var $nesting = [self].concat($parent_nesting), $View_supported$ques$1, $View_initialize$2, $View_length$3, $View_get$4, $View_set$5, $View_get_int8$6, $View_set_int8$7, $View_get_uint8$8, $View_set_uint8$9, $View_get_int16$10, $View_set_int16$11, $View_get_uint16$12, $View_set_uint16$13, $View_get_int32$14, $View_set_int32$15, $View_get_uint32$16, $View_set_uint32$17, $View_get_float32$18, $View_set_float32$19, $View_get_float64$20, $View_set_float64$21; self.$$prototype["native"] = nil; self.$include($$$($$($nesting, 'Native'), 'Wrapper')); Opal.defs(self, '$supported?', $View_supported$ques$1 = function() { var self = this; if ($gvars.$ == null) $gvars.$ = nil; return $gvars.$['$[]']("DataView")['$nil?']()['$!']() }, $View_supported$ques$1.$$arity = 0); self.$attr_reader("buffer", "offset"); Opal.def(self, '$initialize', $View_initialize$2 = function $$initialize(buffer, offset, length) { var $a, $iter = $View_initialize$2.$$p, $yield = $iter || nil, self = this; if ($iter) $View_initialize$2.$$p = null; if (offset == null) { offset = nil; }; if (length == null) { length = nil; }; if ($truthy(self['$native?'](buffer))) { $send(self, Opal.find_super_dispatcher(self, 'initialize', $View_initialize$2, false), [buffer], null) } else if ($truthy(($truthy($a = offset) ? length : $a))) { $send(self, Opal.find_super_dispatcher(self, 'initialize', $View_initialize$2, false), [new DataView(buffer.$to_n(), offset.$to_n(), length.$to_n())], null) } else if ($truthy(offset)) { $send(self, Opal.find_super_dispatcher(self, 'initialize', $View_initialize$2, false), [new DataView(buffer.$to_n(), offset.$to_n())], null) } else { $send(self, Opal.find_super_dispatcher(self, 'initialize', $View_initialize$2, false), [new DataView(buffer.$to_n())], null) }; self.buffer = buffer; return (self.offset = offset); }, $View_initialize$2.$$arity = -2); Opal.def(self, '$length', $View_length$3 = function $$length() { var self = this; return self["native"].byteLength }, $View_length$3.$$arity = 0); Opal.alias(self, "size", "length"); Opal.def(self, '$get', $View_get$4 = function $$get(offset, bits, type, little) { var self = this; if (bits == null) { bits = 8; }; if (type == null) { type = "unsigned"; }; if (little == null) { little = false; }; return self["native"]["get" + $$($nesting, 'Buffer').$name_for(bits, type)](offset, little); }, $View_get$4.$$arity = -2); Opal.alias(self, "[]", "get"); Opal.def(self, '$set', $View_set$5 = function $$set(offset, value, bits, type, little) { var self = this; if (bits == null) { bits = 8; }; if (type == null) { type = "unsigned"; }; if (little == null) { little = false; }; return self["native"]["set" + $$($nesting, 'Buffer').$name_for(bits, type)](offset, value, little); }, $View_set$5.$$arity = -3); Opal.alias(self, "[]=", "set"); Opal.def(self, '$get_int8', $View_get_int8$6 = function $$get_int8(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getInt8(offset, little); }, $View_get_int8$6.$$arity = -2); Opal.def(self, '$set_int8', $View_set_int8$7 = function $$set_int8(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setInt8(offset, value, little); }, $View_set_int8$7.$$arity = -3); Opal.def(self, '$get_uint8', $View_get_uint8$8 = function $$get_uint8(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getUint8(offset, little); }, $View_get_uint8$8.$$arity = -2); Opal.def(self, '$set_uint8', $View_set_uint8$9 = function $$set_uint8(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setUint8(offset, value, little); }, $View_set_uint8$9.$$arity = -3); Opal.def(self, '$get_int16', $View_get_int16$10 = function $$get_int16(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getInt16(offset, little); }, $View_get_int16$10.$$arity = -2); Opal.def(self, '$set_int16', $View_set_int16$11 = function $$set_int16(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setInt16(offset, value, little); }, $View_set_int16$11.$$arity = -3); Opal.def(self, '$get_uint16', $View_get_uint16$12 = function $$get_uint16(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getUint16(offset, little); }, $View_get_uint16$12.$$arity = -2); Opal.def(self, '$set_uint16', $View_set_uint16$13 = function $$set_uint16(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setUint16(offset, value, little); }, $View_set_uint16$13.$$arity = -3); Opal.def(self, '$get_int32', $View_get_int32$14 = function $$get_int32(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getInt32(offset, little); }, $View_get_int32$14.$$arity = -2); Opal.def(self, '$set_int32', $View_set_int32$15 = function $$set_int32(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setInt32(offset, value, little); }, $View_set_int32$15.$$arity = -3); Opal.def(self, '$get_uint32', $View_get_uint32$16 = function $$get_uint32(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getUint32(offset, little); }, $View_get_uint32$16.$$arity = -2); Opal.def(self, '$set_uint32', $View_set_uint32$17 = function $$set_uint32(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setUint32(offset, value, little); }, $View_set_uint32$17.$$arity = -3); Opal.def(self, '$get_float32', $View_get_float32$18 = function $$get_float32(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getFloat32(offset, little); }, $View_get_float32$18.$$arity = -2); Opal.def(self, '$set_float32', $View_set_float32$19 = function $$set_float32(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setFloat32(offset, value, little); }, $View_set_float32$19.$$arity = -3); Opal.def(self, '$get_float64', $View_get_float64$20 = function $$get_float64(offset, little) { var self = this; if (little == null) { little = false; }; return self["native"].getFloat64(offset, little); }, $View_get_float64$20.$$arity = -2); return (Opal.def(self, '$set_float64', $View_set_float64$21 = function $$set_float64(offset, value, little) { var self = this; if (little == null) { little = false; }; return self["native"].setFloat64(offset, value, little); }, $View_set_float64$21.$$arity = -3), nil) && 'set_float64'; })($nesting[0], null, $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["buffer"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $gvars = Opal.gvars, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$require', '$include', '$!', '$nil?', '$[]', '$===', '$native?', '$new']); self.$require("native"); self.$require("buffer/array"); self.$require("buffer/view"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Buffer'); var $nesting = [self].concat($parent_nesting), $Buffer_supported$ques$1, $Buffer_name_for$2, $Buffer_initialize$3, $Buffer_length$4, $Buffer_to_a$5, $Buffer_view$6; self.$$prototype["native"] = nil; self.$include($$$($$($nesting, 'Native'), 'Wrapper')); Opal.defs(self, '$supported?', $Buffer_supported$ques$1 = function() { var self = this; if ($gvars.$ == null) $gvars.$ = nil; return $gvars.$['$[]']("ArrayBuffer")['$nil?']()['$!']() }, $Buffer_supported$ques$1.$$arity = 0); Opal.defs(self, '$name_for', $Buffer_name_for$2 = function $$name_for(bits, type) { var self = this, part = nil, $case = nil; part = (function() {$case = type; if ("unsigned"['$===']($case)) {return "Uint"} else if ("signed"['$===']($case)) {return "Int"} else if ("float"['$===']($case)) {return "Float"} else { return nil }})(); return "" + (part) + (bits); }, $Buffer_name_for$2.$$arity = 2); Opal.def(self, '$initialize', $Buffer_initialize$3 = function $$initialize(size, bits) { var $iter = $Buffer_initialize$3.$$p, $yield = $iter || nil, self = this; if ($iter) $Buffer_initialize$3.$$p = null; if (bits == null) { bits = 8; }; if ($truthy(self['$native?'](size))) { return $send(self, Opal.find_super_dispatcher(self, 'initialize', $Buffer_initialize$3, false), [size], null) } else { return $send(self, Opal.find_super_dispatcher(self, 'initialize', $Buffer_initialize$3, false), [new ArrayBuffer(size * (bits / 8))], null) }; }, $Buffer_initialize$3.$$arity = -2); Opal.def(self, '$length', $Buffer_length$4 = function $$length() { var self = this; return self["native"].byteLength }, $Buffer_length$4.$$arity = 0); Opal.alias(self, "size", "length"); Opal.def(self, '$to_a', $Buffer_to_a$5 = function $$to_a(bits, type) { var self = this; if (bits == null) { bits = 8; }; if (type == null) { type = "unsigned"; }; return $$($nesting, 'Array').$new(self, bits, type); }, $Buffer_to_a$5.$$arity = -1); return (Opal.def(self, '$view', $Buffer_view$6 = function $$view(offset, length) { var self = this; if (offset == null) { offset = nil; }; if (length == null) { length = nil; }; return $$($nesting, 'View').$new(self, offset, length); }, $Buffer_view$6.$$arity = -1), nil) && 'view'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/message"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$require', '$supports?', '$convert', '$supported?', '$new', '$alias_native']); self.$require("buffer"); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Message'); var $nesting = [self].concat($parent_nesting), $Message_supported$ques$1, $Message_construct$5, $Message_construct$6, $Message_data$7, $Message_source$8; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $Message_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Message") }, $Message_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_data$eq$2, $Definition_origin$eq$3, $Definition_source$eq$4; self.$$prototype["native"] = nil; Opal.def(self, '$data=', $Definition_data$eq$2 = function(value) { var self = this; return self["native"].data = value }, $Definition_data$eq$2.$$arity = 1); Opal.def(self, '$origin=', $Definition_origin$eq$3 = function(value) { var self = this; return self["native"].origin = value }, $Definition_origin$eq$3.$$arity = 1); return (Opal.def(self, '$source=', $Definition_source$eq$4 = function(value) { var self = this; return self["native"].source = $$($nesting, 'Native').$convert(value) }, $Definition_source$eq$4.$$arity = 1), nil) && 'source='; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Message_construct$5 = function $$construct(name, desc) { var self = this; return new MessageEvent(name, desc) }, $Message_construct$5.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Message_construct$6 = function $$construct(name, desc) { var self = this; var event = document.createEvent("MessageEvent"); event.initMessageEvent(name, desc.bubbles, desc.cancelable, desc.data, desc.origin, "", desc.source || window); return event; }, $Message_construct$6.$$arity = 2)}}; Opal.def(self, '$data', $Message_data$7 = function $$data() { var self = this; if (window.ArrayBuffer && self["native"].data instanceof ArrayBuffer) { return $$($nesting, 'Buffer').$new(self["native"].data); } else if (window.Blob && self["native"].data instanceof Blob) { return $$($nesting, 'Blob').$new(self["native"].data); } else { return self["native"].data; } }, $Message_data$7.$$arity = 0); self.$alias_native("origin"); return (Opal.def(self, '$source', $Message_source$8 = function $$source() { var self = this; var source = self["native"].source; if (window.Window && source instanceof window.Window) { return $$($nesting, 'Window').$new(source); } else { return nil; } }, $Message_source$8.$$arity = 0), nil) && 'source'; })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event/close"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$supports?', '$supported?', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Close'); var $nesting = [self].concat($parent_nesting), $Close_supported$ques$1, $Close_construct$6, $Close_construct$7; Opal.defs(self, '$supported?', $Close_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("Event.Close") }, $Close_supported$ques$1.$$arity = 0); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Definition'); var $nesting = [self].concat($parent_nesting), $Definition_code$eq$2, $Definition_reason$eq$3, $Definition_clean$excl$4, $Definition_not_clean$excl$5; self.$$prototype["native"] = nil; Opal.def(self, '$code=', $Definition_code$eq$2 = function(value) { var self = this; return self["native"].code = value }, $Definition_code$eq$2.$$arity = 1); Opal.def(self, '$reason=', $Definition_reason$eq$3 = function(value) { var self = this; return self["native"].reason = value }, $Definition_reason$eq$3.$$arity = 1); Opal.def(self, '$clean!', $Definition_clean$excl$4 = function(value) { var self = this; return self["native"].wasClean = true }, $Definition_clean$excl$4.$$arity = 1); return (Opal.def(self, '$not_clean!', $Definition_not_clean$excl$5 = function(value) { var self = this; return self["native"].wasClean = false }, $Definition_not_clean$excl$5.$$arity = 1), nil) && 'not_clean!'; })($nesting[0], $$($nesting, 'Definition'), $nesting); if ($truthy(self['$supported?']())) { if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Close_construct$6 = function $$construct(name, desc) { var self = this; return new CloseEvent(name, desc) }, $Close_construct$6.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Close_construct$7 = function $$construct(name, desc) { var self = this; var event = document.createEvent("CloseEvent"); event.initCloseEvent(name, desc.bubbles, desc.cancelable, desc.wasClean, desc.code, desc.reason); return event; }, $Close_construct$7.$$arity = 2)}}; self.$alias_native("code"); self.$alias_native("reason"); return self.$alias_native("clean?", "wasClean"); })($nesting[0], $$($nesting, 'Event'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/event"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2, $send = Opal.send; Opal.add_stubs(['$require', '$gsub', '$[]', '$aliases', '$name_for', '$===', '$class_for', '$new', '$construct', '$const_get', '$to_proc', '$arguments=', '$-', '$supports?', '$merge!', '$Native', '$to_n', '$==', '$name', '$attr_reader', '$attr_writer', '$convert', '$alias_native', '$off', '$prevent', '$stop']); self.$require("browser/event/base"); self.$require("browser/event/ui"); self.$require("browser/event/mouse"); self.$require("browser/event/keyboard"); self.$require("browser/event/focus"); self.$require("browser/event/wheel"); self.$require("browser/event/composition"); self.$require("browser/event/animation"); self.$require("browser/event/audio_processing"); self.$require("browser/event/before_unload"); self.$require("browser/event/composition"); self.$require("browser/event/clipboard"); self.$require("browser/event/device_light"); self.$require("browser/event/device_motion"); self.$require("browser/event/device_orientation"); self.$require("browser/event/device_proximity"); self.$require("browser/event/drag"); self.$require("browser/event/gamepad"); self.$require("browser/event/hash_change"); self.$require("browser/event/progress"); self.$require("browser/event/page_transition"); self.$require("browser/event/pop_state"); self.$require("browser/event/storage"); self.$require("browser/event/touch"); self.$require("browser/event/sensor"); self.$require("browser/event/custom"); self.$require("browser/event/message"); self.$require("browser/event/close"); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Event'); var $nesting = [self].concat($parent_nesting), $Event_aliases$1, $Event_name_for$2, $Event_class_for$3, $Event_supported$ques$4, $Event_create$5, $Event_construct$6, $Event_construct$7, $Event_construct$8, $Event_construct$9, $Event_new$10, $Event_initialize$11, $Event_name$12, $Event_on$13, $Event_target$14, $Event_arguments$15, $Event_arguments$eq$16, $Event_off$17, $Event_stopped$ques$18, $Event_stop$19, $Event_prevent$20, $Event_prevented$ques$21, $Event_stop$excl$22; self.$$prototype["native"] = self.$$prototype.on = self.$$prototype.callback = nil; Opal.defs(self, '$aliases', $Event_aliases$1 = function $$aliases() { var $a, self = this; if (self.aliases == null) self.aliases = nil; return (self.aliases = ($truthy($a = self.aliases) ? $a : $hash2(["dom:load", "hover"], {"dom:load": "DOMContentLoaded", "hover": "mouse:over"}))) }, $Event_aliases$1.$$arity = 0); Opal.defs(self, '$name_for', $Event_name_for$2 = function $$name_for(name) { var $a, self = this; return ($truthy($a = self.$aliases()['$[]'](name)) ? $a : name).$gsub(":", "") }, $Event_name_for$2.$$arity = 1); Opal.defs(self, '$class_for', $Event_class_for$3 = function $$class_for(name) { var self = this, $case = nil; return (function() {$case = self.$name_for(name); if ("animationend"['$===']($case) || "animationiteration"['$===']($case) || "animationstart"['$===']($case)) {return $$($nesting, 'Animation')} else if ("audioprocess"['$===']($case)) {return $$($nesting, 'AudioProcessing')} else if ("beforeunload"['$===']($case)) {return $$($nesting, 'BeforeUnload')} else if ("compositionend"['$===']($case) || "compositionstart"['$===']($case) || "compositionupdate"['$===']($case)) {return $$($nesting, 'Composition')} else if ("copy"['$===']($case) || "cut"['$===']($case)) {return $$($nesting, 'Clipboard')} else if ("devicelight"['$===']($case)) {return $$($nesting, 'DeviceLight')} else if ("devicemotion"['$===']($case)) {return $$($nesting, 'DeviceMotion')} else if ("deviceorientation"['$===']($case)) {return $$($nesting, 'DeviceOrientation')} else if ("deviceproximity"['$===']($case)) {return $$($nesting, 'DeviceProximity')} else if ("drag"['$===']($case) || "dragend"['$===']($case) || "dragleave"['$===']($case) || "dragover"['$===']($case) || "dragstart"['$===']($case) || "drop"['$===']($case)) {return $$($nesting, 'Drag')} else if ("gamepadconnected"['$===']($case) || "gamepaddisconnected"['$===']($case)) {return $$($nesting, 'Gamepad')} else if ("hashchange"['$===']($case)) {return $$($nesting, 'HashChange')} else if ("load"['$===']($case) || "loadend"['$===']($case) || "loadstart"['$===']($case)) {return $$($nesting, 'Progress')} else if ("pagehide"['$===']($case) || "pageshow"['$===']($case)) {return $$($nesting, 'PageTransition')} else if ("popstate"['$===']($case)) {return $$($nesting, 'PopState')} else if ("storage"['$===']($case)) {return $$($nesting, 'Storage')} else if ("touchcancel"['$===']($case) || "touchend"['$===']($case) || "touchleave"['$===']($case) || "touchmove"['$===']($case) || "touchstart"['$===']($case)) {return $$($nesting, 'Touch')} else if ("compassneedscalibration"['$===']($case) || "userproximity"['$===']($case)) {return $$($nesting, 'Sensor')} else if ("message"['$===']($case)) {return $$($nesting, 'Message')} else if ("close"['$===']($case)) {return $$($nesting, 'Close')} else if ("click"['$===']($case) || "contextmenu"['$===']($case) || "dblclick"['$===']($case) || "mousedown"['$===']($case) || "mouseenter"['$===']($case) || "mouseleave"['$===']($case) || "mousemove"['$===']($case) || "mouseout"['$===']($case) || "mouseover"['$===']($case) || "mouseup"['$===']($case) || "show"['$===']($case)) {return $$($nesting, 'Mouse')} else if ("keydown"['$===']($case) || "keypress"['$===']($case) || "keyup"['$===']($case)) {return $$($nesting, 'Keyboard')} else if ("blur"['$===']($case) || "focus"['$===']($case) || "focusin"['$===']($case) || "focusout"['$===']($case)) {return $$($nesting, 'Focus')} else if ("wheel"['$===']($case)) {return $$($nesting, 'Wheel')} else if ("abort"['$===']($case) || "afterprint"['$===']($case) || "beforeprint"['$===']($case) || "cached"['$===']($case) || "canplay"['$===']($case) || "canplaythrough"['$===']($case) || "change"['$===']($case) || "chargingchange"['$===']($case) || "chargingtimechange"['$===']($case) || "checking"['$===']($case) || "close"['$===']($case) || "dischargingtimechange"['$===']($case) || "DOMContentLoaded"['$===']($case) || "downloading"['$===']($case) || "durationchange"['$===']($case) || "emptied"['$===']($case) || "ended"['$===']($case) || "error"['$===']($case) || "fullscreenchange"['$===']($case) || "fullscreenerror"['$===']($case) || "input"['$===']($case) || "invalid"['$===']($case) || "levelchange"['$===']($case) || "loadeddata"['$===']($case) || "loadedmetadata"['$===']($case) || "noupdate"['$===']($case) || "obsolete"['$===']($case) || "offline"['$===']($case) || "online"['$===']($case) || "open"['$===']($case) || "orientationchange"['$===']($case) || "pause"['$===']($case) || "pointerlockchange"['$===']($case) || "pointerlockerror"['$===']($case) || "play"['$===']($case) || "playing"['$===']($case) || "ratechange"['$===']($case) || "readystatechange"['$===']($case) || "reset"['$===']($case) || "seeked"['$===']($case) || "seeking"['$===']($case) || "stalled"['$===']($case) || "submit"['$===']($case) || "success"['$===']($case) || "suspend"['$===']($case) || "timeupdate"['$===']($case) || "updateready"['$===']($case) || "visibilitychange"['$===']($case) || "volumechange"['$===']($case) || "waiting"['$===']($case)) {return $$($nesting, 'Event')} else {return $$($nesting, 'Custom')}})() }, $Event_class_for$3.$$arity = 1); Opal.defs(self, '$supported?', $Event_supported$ques$4 = function() { var self = this; return true }, $Event_supported$ques$4.$$arity = 0); Opal.defs(self, '$create', $Event_create$5 = function $$create(name, $a) { var $iter = $Event_create$5.$$p, block = $iter || nil, $post_args, args, self = this, klass = nil, event = nil, $writer = nil; if ($iter) $Event_create$5.$$p = null; if ($iter) $Event_create$5.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; name = self.$name_for(name); klass = self.$class_for(name); event = klass.$new(klass.$construct(name, $send(klass.$const_get("Definition"), 'new', [], block.$to_proc()))); $writer = [args]; $send(event, 'arguments=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; return event; }, $Event_create$5.$$arity = -2); if ($truthy($$($nesting, 'Browser')['$supports?']("Event.constructor"))) { Opal.defs(self, '$construct', $Event_construct$6 = function $$construct(name, desc) { var self = this; return new Event(name, desc) }, $Event_construct$6.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.create"))) { Opal.defs(self, '$construct', $Event_construct$7 = function $$construct(name, desc) {try { var self = this; var event = document.createEvent("HTMLEvents"); event.initEvent(name, desc.bubbles, desc.cancelable); Opal.ret(self.$Native(event)['$merge!'](desc)); } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Event_construct$7.$$arity = 2) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.createObject"))) { Opal.defs(self, '$construct', $Event_construct$8 = function $$construct(name, desc) { var self = this; return self.$Native(document.createEventObject())['$merge!'](desc)['$merge!']({ type: name }).$to_n() }, $Event_construct$8.$$arity = 2) } else { Opal.defs(self, '$construct', $Event_construct$9 = function $$construct(name, desc) { var self = this; return self.$Native(desc)['$merge!']({ type: name }).$to_n() }, $Event_construct$9.$$arity = 2) }; Opal.defs(self, '$new', $Event_new$10 = function(value, callback) { var $iter = $Event_new$10.$$p, $yield = $iter || nil, self = this, klass = nil, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Event_new$10.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if (callback == null) { callback = nil; }; if (self['$==']($$($nesting, 'Event'))) { } else { return $send(self, Opal.find_super_dispatcher(self, 'new', $Event_new$10, false, self.$$class.$$prototype), $zuper, $iter) }; klass = self.$class_for((function() {if ($truthy(callback)) { return callback.$name() } else { return value.type; }; return nil; })()); if (klass['$==']($$($nesting, 'Event'))) { return $send(self, Opal.find_super_dispatcher(self, 'new', $Event_new$10, false, self.$$class.$$prototype), $zuper, $iter) } else { return klass.$new(value, callback) }; }, $Event_new$10.$$arity = -2); self.$attr_reader("callback"); self.$attr_writer("on"); Opal.def(self, '$initialize', $Event_initialize$11 = function $$initialize(event, callback) { var $iter = $Event_initialize$11.$$p, $yield = $iter || nil, self = this; if ($iter) $Event_initialize$11.$$p = null; if (callback == null) { callback = nil; }; $send(self, Opal.find_super_dispatcher(self, 'initialize', $Event_initialize$11, false), [event], null); return (self.callback = callback); }, $Event_initialize$11.$$arity = -2); Opal.def(self, '$name', $Event_name$12 = function $$name() { var self = this; return self["native"].type }, $Event_name$12.$$arity = 0); Opal.def(self, '$on', $Event_on$13 = function $$on() { var $a, self = this; return ($truthy($a = self.on) ? $a : $$($nesting, 'Target').$convert(self["native"].currentTarget)) }, $Event_on$13.$$arity = 0); Opal.def(self, '$target', $Event_target$14 = function $$target() { var self = this; return $$($nesting, 'Target').$convert(self["native"].srcElement || self["native"].target) }, $Event_target$14.$$arity = 0); Opal.def(self, '$arguments', $Event_arguments$15 = function() { var self = this; return self["native"].arguments || [] }, $Event_arguments$15.$$arity = 0); Opal.def(self, '$arguments=', $Event_arguments$eq$16 = function(args) { var self = this; return self["native"].arguments = args }, $Event_arguments$eq$16.$$arity = 1); self.$alias_native("bubbles?", "bubbles"); self.$alias_native("cancelable?", "cancelable"); self.$alias_native("data"); self.$alias_native("phase", "eventPhase"); self.$alias_native("at", "timeStamp"); Opal.def(self, '$off', $Event_off$17 = function $$off() { var self = this; if ($truthy(self.callback)) { return self.callback.$off() } else { return nil } }, $Event_off$17.$$arity = 0); Opal.def(self, '$stopped?', $Event_stopped$ques$18 = function() { var self = this; return !!self["native"].stopped }, $Event_stopped$ques$18.$$arity = 0); Opal.def(self, '$stop', $Event_stop$19 = function $$stop() { var self = this; if ($truthy((typeof(self["native"].stopPropagation) !== "undefined"))) { self["native"].stopPropagation()}; return self["native"].stopped = true; }, $Event_stop$19.$$arity = 0); Opal.def(self, '$prevent', $Event_prevent$20 = function $$prevent() { var self = this; if ($truthy((typeof(self["native"].preventDefault) !== "undefined"))) { self["native"].preventDefault()}; return self["native"].prevented = true; }, $Event_prevent$20.$$arity = 0); Opal.def(self, '$prevented?', $Event_prevented$ques$21 = function() { var self = this; return !!self["native"].prevented }, $Event_prevented$ques$21.$$arity = 0); return (Opal.def(self, '$stop!', $Event_stop$excl$22 = function() { var self = this; self.$prevent(); return self.$stop(); }, $Event_stop$excl$22.$$arity = 0), nil) && 'stop!'; })($nesting[0], null, $nesting) })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/window/view"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$to_n', '$supports?', '$raise']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Window'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'View'); var $nesting = [self].concat($parent_nesting), $View_initialize$1, $View_width$2, $View_height$3, $View_height$4, $View_width$5, $View_width$6, $View_height$7; self.$$prototype["native"] = nil; Opal.def(self, '$initialize', $View_initialize$1 = function $$initialize(window) { var self = this; self.window = window; return (self["native"] = window.$to_n()); }, $View_initialize$1.$$arity = 1); if ($truthy($$($nesting, 'Browser')['$supports?']("Window.innerSize"))) { Opal.def(self, '$width', $View_width$2 = function $$width() { var self = this; return self["native"].innerWidth }, $View_width$2.$$arity = 0); return (Opal.def(self, '$height', $View_height$3 = function $$height() { var self = this; return self["native"].innerHeight }, $View_height$3.$$arity = 0), nil) && 'height'; } else if ($truthy($$($nesting, 'Browser')['$supports?']("Element.clientSize"))) { Opal.def(self, '$height', $View_height$4 = function $$height() { var self = this; return self["native"].document.documentElement.clientHeight }, $View_height$4.$$arity = 0); return (Opal.def(self, '$width', $View_width$5 = function $$width() { var self = this; return self["native"].document.documentElement.clientWidth }, $View_width$5.$$arity = 0), nil) && 'width'; } else { Opal.def(self, '$width', $View_width$6 = function $$width() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "window size unsupported") }, $View_width$6.$$arity = 0); return (Opal.def(self, '$height', $View_height$7 = function $$height() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "window size unsupported") }, $View_height$7.$$arity = 0), nil) && 'height'; }; })($nesting[0], null, $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/window/size"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2; Opal.add_stubs(['$to_n', '$===', '$first', '$values_at', '$width', '$height', '$supports?', '$raise', '$set']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Window'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Size'); var $nesting = [self].concat($parent_nesting), $Size_initialize$1, $Size_set$2, $Size_width$3, $Size_height$4, $Size_width$5, $Size_height$6, $Size_width$eq$7, $Size_height$eq$8; self.$$prototype["native"] = nil; Opal.def(self, '$initialize', $Size_initialize$1 = function $$initialize(window) { var self = this; self.window = window; return (self["native"] = window.$to_n()); }, $Size_initialize$1.$$arity = 1); Opal.def(self, '$set', $Size_set$2 = function $$set($a) { var $post_args, args, $b, $c, self = this, width = nil, height = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($$($nesting, 'Hash')['$==='](args.$first()))) { $c = args.$first().$values_at("width", "height"), $b = Opal.to_ary($c), (width = ($b[0] == null ? nil : $b[0])), (height = ($b[1] == null ? nil : $b[1])), $c } else { $c = args, $b = Opal.to_ary($c), (width = ($b[0] == null ? nil : $b[0])), (height = ($b[1] == null ? nil : $b[1])), $c }; width = ($truthy($b = width) ? $b : self.$width()); height = ($truthy($b = height) ? $b : self.$height()); self["native"].resizeTo(width, height); return self; }, $Size_set$2.$$arity = -1); if ($truthy($$($nesting, 'Browser')['$supports?']("Window.outerSize"))) { Opal.def(self, '$width', $Size_width$3 = function $$width() { var self = this; return self["native"].outerWidth }, $Size_width$3.$$arity = 0); Opal.def(self, '$height', $Size_height$4 = function $$height() { var self = this; return self["native"].outerHeight }, $Size_height$4.$$arity = 0); } else { Opal.def(self, '$width', $Size_width$5 = function $$width() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "window outer size not supported") }, $Size_width$5.$$arity = 0); Opal.def(self, '$height', $Size_height$6 = function $$height() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "window outer size not supported") }, $Size_height$6.$$arity = 0); }; Opal.def(self, '$width=', $Size_width$eq$7 = function(value) { var self = this; return self.$set($hash2(["width"], {"width": value})) }, $Size_width$eq$7.$$arity = 1); return (Opal.def(self, '$height=', $Size_height$eq$8 = function(value) { var self = this; return self.$set($hash2(["height"], {"height": value})) }, $Size_height$eq$8.$$arity = 1), nil) && 'height='; })($nesting[0], null, $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/window/scroll"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$to_n', '$supports?', '$new', '$raise', '$x', '$position', '$y', '$[]']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Window'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Scroll'); var $nesting = [self].concat($parent_nesting), $Scroll_initialize$1, $Scroll_position$2, $Scroll_position$3, $Scroll_position$4, $Scroll_x$5, $Scroll_y$6, $Scroll_to$7, $Scroll_by$8; self.$$prototype["native"] = nil; Opal.def(self, '$initialize', $Scroll_initialize$1 = function $$initialize(window) { var self = this; self.window = window; return (self["native"] = window.$to_n()); }, $Scroll_initialize$1.$$arity = 1); if ($truthy($$($nesting, 'Browser')['$supports?']("Window.scroll"))) { Opal.def(self, '$position', $Scroll_position$2 = function $$position() { var self = this; var doc = self["native"].document, root = doc.documentElement, body = doc.body; var x = root.scrollLeft || body.scrollLeft, y = root.scrollTop || body.scrollTop; ; return $$($nesting, 'Position').$new(x, y); }, $Scroll_position$2.$$arity = 0) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Window.pageOffset"))) { Opal.def(self, '$position', $Scroll_position$3 = function $$position() { var self = this; return $$($nesting, 'Position').$new(self["native"].pageXOffset, self["native"].pageYOffset) }, $Scroll_position$3.$$arity = 0) } else { Opal.def(self, '$position', $Scroll_position$4 = function $$position() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "window scroll unsupported") }, $Scroll_position$4.$$arity = 0) }; Opal.def(self, '$x', $Scroll_x$5 = function $$x() { var self = this; return self.$position().$x() }, $Scroll_x$5.$$arity = 0); Opal.def(self, '$y', $Scroll_y$6 = function $$y() { var self = this; return self.$position().$y() }, $Scroll_y$6.$$arity = 0); Opal.def(self, '$to', $Scroll_to$7 = function $$to(what) { var $a, self = this, x = nil, y = nil; x = ($truthy($a = what['$[]']("x")) ? $a : self.$x()); y = ($truthy($a = what['$[]']("y")) ? $a : self.$y()); self["native"].scrollTo(x, y); return self; }, $Scroll_to$7.$$arity = 1); return (Opal.def(self, '$by', $Scroll_by$8 = function $$by(what) { var $a, self = this, x = nil, y = nil; x = ($truthy($a = what['$[]']("x")) ? $a : 0); y = ($truthy($a = what['$[]']("y")) ? $a : 0); self["native"].scrollBy(x, y); return self; }, $Scroll_by$8.$$arity = 1), nil) && 'by'; })($nesting[0], null, $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/window"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $gvars = Opal.gvars, $hash2 = Opal.hash2; Opal.add_stubs(['$require', '$delete', '$join', '$map', '$===', '$new', '$include', '$target', '$supports?', '$[]', '$raise', '$alert', '$prompt', '$confirm']); self.$require("browser/window/view"); self.$require("browser/window/size"); self.$require("browser/window/scroll"); (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Window'); var $nesting = [self].concat($parent_nesting), $Window_open$1, $Window$3, $Window_alert$4, $Window_prompt$5, $Window_confirm$6, $Window_view$7, $Window_size$8, $Window_scroll$9, $Window_send$10, $Window_send$11, $Window_close$12; self.$$prototype["native"] = nil; Opal.defs(self, '$open', $Window_open$1 = function $$open(url, options) { var $$2, self = this, name = nil, features = nil; name = options.$delete("name"); features = $send(options, 'map', [], ($$2 = function(key, value){var self = $$2.$$s || this, $case = nil; if (key == null) { key = nil; }; if (value == null) { value = nil; }; value = (function() {$case = value; if (true['$===']($case)) {return "yes"} else if (false['$===']($case)) {return "no"} else {return value}})(); return "" + (key) + "=" + (value);}, $$2.$$s = self, $$2.$$arity = 2, $$2)).$join(","); var win = window.open(url, name, features); if (win == null) { return nil; } return self.$new(win); ; }, $Window_open$1.$$arity = 2); self.$include($$($nesting, 'Native')); self.$include($$$($$($nesting, 'Event'), 'Target')); $send(self, 'target', [], ($Window$3 = function(value){var self = $Window$3.$$s || this; if ($gvars.window == null) $gvars.window = nil; if (value == null) { value = nil; }; if ($truthy(value == window)) { return $gvars.window } else { return nil };}, $Window$3.$$s = self, $Window$3.$$arity = 1, $Window$3)); Opal.def(self, '$alert', $Window_alert$4 = function $$alert(value) { var self = this; self["native"].alert(value); return value; }, $Window_alert$4.$$arity = 1); Opal.def(self, '$prompt', $Window_prompt$5 = function $$prompt(value) { var self = this; return self["native"].prompt(value) || nil }, $Window_prompt$5.$$arity = 1); Opal.def(self, '$confirm', $Window_confirm$6 = function $$confirm(value) { var self = this; return self["native"].confirm(value) || false }, $Window_confirm$6.$$arity = 1); Opal.def(self, '$view', $Window_view$7 = function $$view() { var self = this; return $$($nesting, 'View').$new(self) }, $Window_view$7.$$arity = 0); Opal.def(self, '$size', $Window_size$8 = function $$size() { var self = this; return $$($nesting, 'Size').$new(self) }, $Window_size$8.$$arity = 0); Opal.def(self, '$scroll', $Window_scroll$9 = function $$scroll() { var self = this; return $$($nesting, 'Scroll').$new(self) }, $Window_scroll$9.$$arity = 0); if ($truthy($$($nesting, 'Browser')['$supports?']("Window.send"))) { Opal.def(self, '$send', $Window_send$10 = function $$send(message, options) { var $a, self = this; if (options == null) { options = $hash2([], {}); }; return self["native"].postMessage(message, ($truthy($a = options['$[]']("to")) ? $a : "*")); }, $Window_send$10.$$arity = -2) } else { Opal.def(self, '$send', $Window_send$11 = function $$send(message, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return self.$raise($$($nesting, 'NotImplementedError'), "message sending unsupported"); }, $Window_send$11.$$arity = -2) }; return (Opal.def(self, '$close', $Window_close$12 = function $$close() { var self = this; return (window.open('', '_self', '') && window.close()) || (window.opener = null && window.close()) || (window.opener = '' && window.close()); }, $Window_close$12.$$arity = 0), nil) && 'close'; })($nesting[0], null, $nesting) })($nesting[0], $nesting); $gvars.window = $$$($$($nesting, 'Browser'), 'Window').$new(window); return (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_alert$13, $Kernel_prompt$14, $Kernel_confirm$15; Opal.def(self, '$alert', $Kernel_alert$13 = function $$alert(value) { var self = this; if ($gvars.window == null) $gvars.window = nil; return $gvars.window.$alert(value) }, $Kernel_alert$13.$$arity = 1); Opal.def(self, '$prompt', $Kernel_prompt$14 = function $$prompt(value) { var self = this; if ($gvars.window == null) $gvars.window = nil; return $gvars.window.$prompt(value) }, $Kernel_prompt$14.$$arity = 1); Opal.def(self, '$confirm', $Kernel_confirm$15 = function $$confirm(value) { var self = this; if ($gvars.window == null) $gvars.window = nil; return $gvars.window.$confirm(value) }, $Kernel_confirm$15.$$arity = 1); })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/node_set"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy; Opal.add_stubs(['$new', '$uniq', '$map', '$flatten', '$DOM', '$convert', '$respond_to?', '$each', '$__send__', '$to_proc', '$===', '$at_css', '$at_xpath', '$[]', '$css', '$select', '$=~', '$search', '$xpath']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'NodeSet'); var $nesting = [self].concat($parent_nesting), $NodeSet_$$$1, $NodeSet_initialize$3, $NodeSet_method_missing$4, $NodeSet_at_css$6, $NodeSet_at_xpath$8, $NodeSet_css$10, $NodeSet_filter$12, $NodeSet_search$14, $NodeSet_xpath$16, $NodeSet_to_ary$18; self.$$prototype.literal = nil; Opal.defs(self, '$[]', $NodeSet_$$$1 = function($a) { var $post_args, nodes, $$2, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); nodes = $post_args;; return self.$new($send(nodes.$flatten(), 'map', [], ($$2 = function(x){var self = $$2.$$s || this; if (x == null) { x = nil; }; return self.$DOM($$($nesting, 'Native').$convert(x));}, $$2.$$s = self, $$2.$$arity = 1, $$2)).$uniq()); }, $NodeSet_$$$1.$$arity = -1); Opal.def(self, '$initialize', $NodeSet_initialize$3 = function $$initialize(literal) { var self = this; return (self.literal = literal) }, $NodeSet_initialize$3.$$arity = 1); Opal.def(self, '$method_missing', $NodeSet_method_missing$4 = function $$method_missing(name, $a) { var $iter = $NodeSet_method_missing$4.$$p, block = $iter || nil, $post_args, args, $$5, self = this, result = nil; if ($iter) $NodeSet_method_missing$4.$$p = null; if ($iter) $NodeSet_method_missing$4.$$p = null;; $post_args = Opal.slice.call(arguments, 1, arguments.length); args = $post_args;; if ($truthy(self.literal['$respond_to?'](name))) { } else { $send(self, 'each', [], ($$5 = function(el){var self = $$5.$$s || this; if (el == null) { el = nil; }; return $send(el, '__send__', [name].concat(Opal.to_a(args)), block.$to_proc());}, $$5.$$s = self, $$5.$$arity = 1, $$5)); return self; }; result = $send(self.literal, '__send__', [name].concat(Opal.to_a(args)), block.$to_proc()); if ($truthy(result === self.literal)) { return self } else if ($truthy($$($nesting, 'Array')['$==='](result))) { return $$($nesting, 'NodeSet').$new(result) } else { return result }; }, $NodeSet_method_missing$4.$$arity = -2); Opal.def(self, '$at_css', $NodeSet_at_css$6 = function $$at_css($a) {try { var $post_args, rules, $$7, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); rules = $post_args;; $send(self, 'each', [], ($$7 = function(node){var self = $$7.$$s || this; if (node == null) { node = nil; }; if ($truthy((node = $send(node, 'at_css', Opal.to_a(rules))))) { Opal.ret(node) } else { return nil };}, $$7.$$s = self, $$7.$$arity = 1, $$7)); return nil; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $NodeSet_at_css$6.$$arity = -1); Opal.def(self, '$at_xpath', $NodeSet_at_xpath$8 = function $$at_xpath($a) {try { var $post_args, paths, $$9, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); paths = $post_args;; $send(self, 'each', [], ($$9 = function(node){var self = $$9.$$s || this; if (node == null) { node = nil; }; if ($truthy((node = $send(node, 'at_xpath', Opal.to_a(paths))))) { Opal.ret(node) } else { return nil };}, $$9.$$s = self, $$9.$$arity = 1, $$9)); return nil; } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $NodeSet_at_xpath$8.$$arity = -1); Opal.def(self, '$css', $NodeSet_css$10 = function $$css(path) { var $$11, self = this; return $$($nesting, 'NodeSet')['$[]']($send(self.literal, 'map', [], ($$11 = function(node){var self = $$11.$$s || this; if (node == null) { node = nil; }; return node.$css(path);}, $$11.$$s = self, $$11.$$arity = 1, $$11))) }, $NodeSet_css$10.$$arity = 1); Opal.def(self, '$filter', $NodeSet_filter$12 = function $$filter(expression) { var $$13, self = this; return $send(self.literal, 'select', [], ($$13 = function(node){var self = $$13.$$s || this; if (node == null) { node = nil; }; return node['$=~'](expression);}, $$13.$$s = self, $$13.$$arity = 1, $$13)) }, $NodeSet_filter$12.$$arity = 1); Opal.def(self, '$search', $NodeSet_search$14 = function $$search($a) { var $post_args, what, $$15, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); what = $post_args;; return $$($nesting, 'NodeSet')['$[]']($send(self.literal, 'map', [], ($$15 = function(node){var self = $$15.$$s || this; if (node == null) { node = nil; }; return $send(node, 'search', Opal.to_a(what));}, $$15.$$s = self, $$15.$$arity = 1, $$15))); }, $NodeSet_search$14.$$arity = -1); Opal.def(self, '$xpath', $NodeSet_xpath$16 = function $$xpath(path) { var $$17, self = this; return $$($nesting, 'NodeSet')['$[]']($send(self.literal, 'map', [], ($$17 = function(node){var self = $$17.$$s || this; if (node == null) { node = nil; }; return node.$xpath(path);}, $$17.$$s = self, $$17.$$arity = 1, $$17))) }, $NodeSet_xpath$16.$$arity = 1); return (Opal.def(self, '$to_ary', $NodeSet_to_ary$18 = function $$to_ary() { var self = this; return self.literal }, $NodeSet_to_ary$18.$$arity = 0), nil) && 'to_ary'; })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/node"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$include', '$==', '$[]', '$new', '$raise', '$convert', '$respond_to?', '$each', '$<<', '$native?', '$===', '$>>', '$DOM', '$to_proc', '$parent', '$last', '$pop', '$select!', '$=~', '$remove_child', '$remove', '$children', '$supports?', '$node_type', '$first', '$select', '$element_children', '$to_s', '$next', '$!', '$element?', '$previous', '$try_convert', '$name']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Node'); var $nesting = [self].concat($parent_nesting), $Node_new$1, $Node_$eq_eq$2, $Node_$lt$lt$3, $Node_$gt$gt$5, $Node_add_child$7, $Node_add_next_sibling$8, $Node_add_previous_sibling$9, $Node_append_to$10, $Node_ancestors$11, $Node_remove$13, $Node_clear$14, $Node_content$15, $Node_content$eq$16, $Node_content$17, $Node_content$eq$18, $Node_content$19, $Node_content$eq$20, $Node_blank$ques$21, $Node_cdata$ques$22, $Node_child$23, $Node_children$24, $Node_children$eq$25, $Node_comment$ques$26, $Node_document$27, $Node_document$ques$28, $Node_elem$ques$29, $Node_element_children$30, $Node_first_element_child$31, $Node_fragment$ques$32, $Node_inner_html$33, $Node_inner_html$eq$34, $Node_last_element_child$35, $Node_name$36, $Node_name$eq$37, $Node_namespace$38, $Node_next$39, $Node_next_element$40, $Node_node_type$41, $Node_parent$42, $Node_parent$eq$43, $Node_parse$44, $Node_path$45, $Node_prepend_to$46, $Node_previous$47, $Node_previous_element$48, $Node_remove_child$49, $Node_replace$50, $Node_text$ques$51, $Node_traverse$52, $Node_value$53, $Node_value$eq$54, $Node_inspect$55; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.const_set($nesting[0], 'ELEMENT_NODE', 1); Opal.const_set($nesting[0], 'ATTRIBUTE_NODE', 2); Opal.const_set($nesting[0], 'TEXT_NODE', 3); Opal.const_set($nesting[0], 'CDATA_SECTION_NODE', 4); Opal.const_set($nesting[0], 'ENTITY_REFERENCE_NOCE', 5); Opal.const_set($nesting[0], 'ENTITY_NODE', 6); Opal.const_set($nesting[0], 'PROCESSING_INSTRUCTION_NODE', 7); Opal.const_set($nesting[0], 'COMMENT_NODE', 8); Opal.const_set($nesting[0], 'DOCUMENT_NODE', 9); Opal.const_set($nesting[0], 'DOCUMENT_TYPE_NODE', 10); Opal.const_set($nesting[0], 'DOCUMENT_FRAGMENT_NODE', 11); Opal.const_set($nesting[0], 'NOTATION_NODE', 12); Opal.defs(self, '$new', $Node_new$1 = function(value) { var $a, $iter = $Node_new$1.$$p, $yield = $iter || nil, self = this, klass = nil, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if (self.classes == null) self.classes = nil; if ($iter) $Node_new$1.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if (self['$==']($$($nesting, 'Node'))) { self.classes = ($truthy($a = self.classes) ? $a : [nil, $$($nesting, 'Element'), $$($nesting, 'Attribute'), $$($nesting, 'Text'), $$($nesting, 'CDATA'), nil, nil, nil, $$($nesting, 'Comment'), $$($nesting, 'Document'), nil, $$($nesting, 'DocumentFragment')]); if ($truthy((klass = self.classes['$[]'](value.nodeType)))) { return klass.$new(value) } else { return self.$raise($$($nesting, 'ArgumentError'), "cannot instantiate a non derived Node object") }; } else { return $send(self, Opal.find_super_dispatcher(self, 'new', $Node_new$1, false, self.$$class.$$prototype), $zuper, $iter) } }, $Node_new$1.$$arity = 1); Opal.def(self, '$==', $Node_$eq_eq$2 = function(other) { var self = this; return self["native"] === $$($nesting, 'Native').$convert(other) }, $Node_$eq_eq$2.$$arity = 1); Opal.def(self, '$<<', $Node_$lt$lt$3 = function(node) { var $$4, self = this; if ($truthy($$($nesting, 'Opal')['$respond_to?'](node, "each"))) { $send(node, 'each', [], ($$4 = function(n){var self = $$4.$$s || this; if (n == null) { n = nil; }; return self['$<<'](n);}, $$4.$$s = self, $$4.$$arity = 1, $$4)); return self;}; if ($truthy(self['$native?'](node))) { } else if ($truthy($$($nesting, 'String')['$==='](node))) { node = self["native"].ownerDocument.createTextNode(node) } else { node = $$($nesting, 'Native').$convert(node) }; self["native"].appendChild(node); return self; }, $Node_$lt$lt$3.$$arity = 1); Opal.def(self, '$>>', $Node_$gt$gt$5 = function(node) { var $$6, self = this; if ($truthy($$($nesting, 'Opal')['$respond_to?'](node, "each"))) { $send(node, 'each', [], ($$6 = function(n){var self = $$6.$$s || this; if (n == null) { n = nil; }; return self['$>>'](n);}, $$6.$$s = self, $$6.$$arity = 1, $$6)); return self;}; if ($truthy(self['$native?'](node))) { } else if ($truthy($$($nesting, 'String')['$==='](node))) { node = self["native"].ownerDocument.createTextNode(node) } else { node = $$($nesting, 'Native').$convert(node) }; if ($truthy(self["native"].firstChild == null)) { self["native"].appendChild(node) } else { self["native"].insertBefore(node, self["native"].firstChild) }; return self; }, $Node_$gt$gt$5.$$arity = 1); Opal.def(self, '$add_child', $Node_add_child$7 = function $$add_child(node) { var $iter = $Node_add_child$7.$$p, block = $iter || nil, self = this; if ($iter) $Node_add_child$7.$$p = null; if ($iter) $Node_add_child$7.$$p = null;; if (node == null) { node = nil; }; if ($truthy(node)) { } else { node = $send(self, 'DOM', [], block.$to_proc()) }; return self['$<<'](node); }, $Node_add_child$7.$$arity = -1); Opal.def(self, '$add_next_sibling', $Node_add_next_sibling$8 = function $$add_next_sibling(node) { var $iter = $Node_add_next_sibling$8.$$p, block = $iter || nil, self = this; if ($iter) $Node_add_next_sibling$8.$$p = null; if ($iter) $Node_add_next_sibling$8.$$p = null;; if (node == null) { node = nil; }; if ($truthy(node)) { } else { node = $send(self, 'DOM', [], block.$to_proc()) }; if ($truthy(self['$native?'](node))) { } else if ($truthy($$($nesting, 'String')['$==='](node))) { node = self["native"].ownerDocument.createTextNode(node) } else { node = $$($nesting, 'Native').$convert(node) }; return self["native"].parentNode.insertBefore(node, self["native"].nextSibling); }, $Node_add_next_sibling$8.$$arity = -1); Opal.def(self, '$add_previous_sibling', $Node_add_previous_sibling$9 = function $$add_previous_sibling(node) { var $iter = $Node_add_previous_sibling$9.$$p, block = $iter || nil, self = this; if ($iter) $Node_add_previous_sibling$9.$$p = null; if ($iter) $Node_add_previous_sibling$9.$$p = null;; if (node == null) { node = nil; }; if ($truthy(node)) { } else { node = $send(self, 'DOM', [], block.$to_proc()) }; if ($truthy(self['$native?'](node))) { } else if ($truthy($$($nesting, 'String')['$==='](node))) { node = self["native"].ownerDocument.createTextNode(node) } else { node = $$($nesting, 'Native').$convert(node) }; return self["native"].parentNode.insertBefore(node, self["native"]); }, $Node_add_previous_sibling$9.$$arity = -1); Opal.alias(self, "after", "add_next_sibling"); Opal.def(self, '$append_to', $Node_append_to$10 = function $$append_to(node) { var self = this; return node['$<<'](self) }, $Node_append_to$10.$$arity = 1); Opal.def(self, '$ancestors', $Node_ancestors$11 = function $$ancestors(expression) { var $a, $$12, self = this, parents = nil, parent = nil; if (expression == null) { expression = nil; }; if ($truthy(self.$parent())) { } else { return $$($nesting, 'NodeSet')['$[]']() }; parents = [self.$parent()]; while ($truthy((parent = parents.$last().$parent()))) { parents['$<<'](parent) }; if ($truthy($$($nesting, 'Document')['$==='](parents.$last()))) { parents.$pop()}; if ($truthy(expression)) { $send(parents, 'select!', [], ($$12 = function(p){var self = $$12.$$s || this; if (p == null) { p = nil; }; return p['$=~'](expression);}, $$12.$$s = self, $$12.$$arity = 1, $$12))}; return $$($nesting, 'NodeSet').$new(parents); }, $Node_ancestors$11.$$arity = -1); Opal.alias(self, "before", "add_previous_sibling"); Opal.def(self, '$remove', $Node_remove$13 = function $$remove() { var self = this; if ($truthy(self.$parent())) { return self.$parent().$remove_child(self) } else { return nil } }, $Node_remove$13.$$arity = 0); Opal.def(self, '$clear', $Node_clear$14 = function $$clear() { var self = this; return self.$children().$remove() }, $Node_clear$14.$$arity = 0); if ($truthy($$($nesting, 'Browser')['$supports?']("Element.textContent"))) { Opal.def(self, '$content', $Node_content$15 = function $$content() { var self = this; return self["native"].textContent }, $Node_content$15.$$arity = 0); Opal.def(self, '$content=', $Node_content$eq$16 = function(value) { var self = this; return self["native"].textContent = value }, $Node_content$eq$16.$$arity = 1); } else if ($truthy($$($nesting, 'Browser')['$supports?']("Element.innerText"))) { Opal.def(self, '$content', $Node_content$17 = function $$content() { var self = this; return self["native"].innerText }, $Node_content$17.$$arity = 0); Opal.def(self, '$content=', $Node_content$eq$18 = function(value) { var self = this; return self["native"].innerText = value }, $Node_content$eq$18.$$arity = 1); } else { Opal.def(self, '$content', $Node_content$19 = function $$content() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "node text content unsupported") }, $Node_content$19.$$arity = 0); Opal.def(self, '$content=', $Node_content$eq$20 = function(value) { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "node text content unsupported") }, $Node_content$eq$20.$$arity = 1); }; Opal.def(self, '$blank?', $Node_blank$ques$21 = function() { var self = this; return self.$raise($$($nesting, 'NotImplementedError')) }, $Node_blank$ques$21.$$arity = 0); Opal.def(self, '$cdata?', $Node_cdata$ques$22 = function() { var self = this; return self.$node_type()['$==']($$($nesting, 'CDATA_SECTION_NODE')) }, $Node_cdata$ques$22.$$arity = 0); Opal.def(self, '$child', $Node_child$23 = function $$child() { var self = this; return self.$children().$first() }, $Node_child$23.$$arity = 0); Opal.def(self, '$children', $Node_children$24 = function $$children() { var self = this; return $$($nesting, 'NodeSet')['$[]']($$$($$($nesting, 'Native'), 'Array').$new(self["native"].childNodes)) }, $Node_children$24.$$arity = 0); Opal.def(self, '$children=', $Node_children$eq$25 = function(node) { var self = this; return self.$raise($$($nesting, 'NotImplementedError')) }, $Node_children$eq$25.$$arity = 1); Opal.def(self, '$comment?', $Node_comment$ques$26 = function() { var self = this; return self.$node_type()['$==']($$($nesting, 'COMMENT_NODE')) }, $Node_comment$ques$26.$$arity = 0); Opal.def(self, '$document', $Node_document$27 = function $$document() { var self = this; if ($truthy((typeof(self["native"].ownerDocument) !== "undefined"))) { return self.$DOM(self["native"].ownerDocument) } else { return nil } }, $Node_document$27.$$arity = 0); Opal.def(self, '$document?', $Node_document$ques$28 = function() { var self = this; return self.$node_type()['$==']($$($nesting, 'DOCUMENT_NODE')) }, $Node_document$ques$28.$$arity = 0); Opal.def(self, '$elem?', $Node_elem$ques$29 = function() { var self = this; return self.$node_type()['$==']($$($nesting, 'ELEMENT_NODE')) }, $Node_elem$ques$29.$$arity = 0); Opal.alias(self, "element?", "elem?"); Opal.def(self, '$element_children', $Node_element_children$30 = function $$element_children() { var self = this; return $send(self.$children(), 'select', [], "element?".$to_proc()) }, $Node_element_children$30.$$arity = 0); Opal.alias(self, "elements", "element_children"); Opal.def(self, '$first_element_child', $Node_first_element_child$31 = function $$first_element_child() { var self = this; return self.$element_children().$first() }, $Node_first_element_child$31.$$arity = 0); Opal.def(self, '$fragment?', $Node_fragment$ques$32 = function() { var self = this; return self.$node_type()['$==']($$($nesting, 'DOCUMENT_FRAGMENT_NODE')) }, $Node_fragment$ques$32.$$arity = 0); Opal.def(self, '$inner_html', $Node_inner_html$33 = function $$inner_html() { var self = this; return self["native"].innerHTML }, $Node_inner_html$33.$$arity = 0); Opal.def(self, '$inner_html=', $Node_inner_html$eq$34 = function(value) { var self = this; return self["native"].innerHTML = value }, $Node_inner_html$eq$34.$$arity = 1); Opal.alias(self, "inner_text", "content"); Opal.alias(self, "inner_text=", "content="); Opal.def(self, '$last_element_child', $Node_last_element_child$35 = function $$last_element_child() { var self = this; return self.$element_children().$last() }, $Node_last_element_child$35.$$arity = 0); Opal.def(self, '$name', $Node_name$36 = function $$name() { var self = this; return self["native"].nodeName || nil }, $Node_name$36.$$arity = 0); Opal.def(self, '$name=', $Node_name$eq$37 = function(value) { var self = this; return self["native"].nodeName = value.$to_s() }, $Node_name$eq$37.$$arity = 1); Opal.def(self, '$namespace', $Node_namespace$38 = function $$namespace() { var self = this; return self["native"].namespaceURI || nil }, $Node_namespace$38.$$arity = 0); Opal.def(self, '$next', $Node_next$39 = function $$next() { var self = this; if ($truthy(self["native"].nextSibling != null)) { return self.$DOM(self["native"].nextSibling) } else { return nil } }, $Node_next$39.$$arity = 0); Opal.alias(self, "next=", "add_next_sibling"); Opal.def(self, '$next_element', $Node_next_element$40 = function $$next_element() { var $a, $b, self = this, current = nil; current = self.$next(); while ($truthy(($truthy($b = current) ? current['$element?']()['$!']() : $b))) { current = current.$next() }; return current; }, $Node_next_element$40.$$arity = 0); Opal.alias(self, "next_sibling", "next"); Opal.alias(self, "node_name", "name"); Opal.alias(self, "node_name=", "name="); Opal.def(self, '$node_type', $Node_node_type$41 = function $$node_type() { var self = this; return self["native"].nodeType }, $Node_node_type$41.$$arity = 0); Opal.def(self, '$parent', $Node_parent$42 = function $$parent() { var self = this; if ($truthy(self["native"].parentNode != null)) { return self.$DOM(self["native"].parentNode) } else { return nil } }, $Node_parent$42.$$arity = 0); Opal.def(self, '$parent=', $Node_parent$eq$43 = function(node) { var self = this; return self["native"].parentNode = $$($nesting, 'Native').$convert(node) }, $Node_parent$eq$43.$$arity = 1); Opal.def(self, '$parse', $Node_parse$44 = function $$parse(text, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return self.$raise($$($nesting, 'NotImplementedError')); }, $Node_parse$44.$$arity = -2); Opal.def(self, '$path', $Node_path$45 = function $$path() { var self = this; return self.$raise($$($nesting, 'NotImplementedError')) }, $Node_path$45.$$arity = 0); Opal.def(self, '$prepend_to', $Node_prepend_to$46 = function $$prepend_to(node) { var self = this; return node['$>>'](self) }, $Node_prepend_to$46.$$arity = 1); Opal.def(self, '$previous', $Node_previous$47 = function $$previous() { var self = this; if ($truthy(self["native"].previousSibling != null)) { return self.$DOM(self["native"].previousSibling) } else { return nil } }, $Node_previous$47.$$arity = 0); Opal.alias(self, "previous=", "add_previous_sibling"); Opal.def(self, '$previous_element', $Node_previous_element$48 = function $$previous_element() { var $a, $b, self = this, current = nil; current = self.$previous(); while ($truthy(($truthy($b = current) ? current['$element?']()['$!']() : $b))) { current = current.$previous() }; return current; }, $Node_previous_element$48.$$arity = 0); Opal.alias(self, "previous_sibling", "previous"); Opal.def(self, '$remove_child', $Node_remove_child$49 = function $$remove_child(node) { var self = this; return self["native"].removeChild($$($nesting, 'Native').$try_convert(node)) }, $Node_remove_child$49.$$arity = 1); Opal.def(self, '$replace', $Node_replace$50 = function $$replace(node) { var self = this; if ($truthy(self['$native?'](node))) { } else if ($truthy($$($nesting, 'String')['$==='](node))) { node = self["native"].ownerDocument.createTextNode(node) } else { node = $$($nesting, 'Native').$convert(node) }; self["native"].parentNode.replaceChild(node, self["native"]); return node; }, $Node_replace$50.$$arity = 1); Opal.alias(self, "replace_with", "replace"); Opal.alias(self, "text", "content"); Opal.alias(self, "text=", "content="); Opal.def(self, '$text?', $Node_text$ques$51 = function() { var self = this; return self.$node_type()['$==']($$($nesting, 'TEXT_NODE')) }, $Node_text$ques$51.$$arity = 0); Opal.def(self, '$traverse', $Node_traverse$52 = function $$traverse() { var $iter = $Node_traverse$52.$$p, block = $iter || nil, self = this; if ($iter) $Node_traverse$52.$$p = null; if ($iter) $Node_traverse$52.$$p = null;; return self.$raise($$($nesting, 'NotImplementedError')); }, $Node_traverse$52.$$arity = 0); Opal.alias(self, "type", "node_type"); Opal.def(self, '$value', $Node_value$53 = function $$value() { var self = this; return self["native"].nodeValue || nil }, $Node_value$53.$$arity = 0); Opal.def(self, '$value=', $Node_value$eq$54 = function(value) { var self = this; return self["native"].nodeValue = value }, $Node_value$eq$54.$$arity = 1); return (Opal.def(self, '$inspect', $Node_inspect$55 = function $$inspect() { var self = this; return "" + "#" }, $Node_inspect$55.$$arity = 0), nil) && 'inspect'; })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/attribute"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$include', '$alias_native', '$supports?', '$==', '$name']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Attribute'); var $nesting = [self].concat($parent_nesting), $Attribute_id$ques$1; self.$include($$($nesting, 'Native')); self.$alias_native("name"); self.$alias_native("value"); self.$alias_native("value="); if ($truthy($$($nesting, 'Browser')['$supports?']("Attr.isId"))) { return self.$alias_native("id?", "isId") } else { return (Opal.def(self, '$id?', $Attribute_id$ques$1 = function() { var self = this; return self.$name()['$==']("id") }, $Attribute_id$ques$1.$$arity = 0), nil) && 'id?' }; })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/character_data"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CharacterData'); var $nesting = [self].concat($parent_nesting), $CharacterData_append$1, $CharacterData_data$2, $CharacterData_delete$3, $CharacterData_insert$4, $CharacterData_replace$5, $CharacterData_substring$6; self.$$prototype["native"] = nil; Opal.def(self, '$append', $CharacterData_append$1 = function $$append(string) { var self = this; self["native"].appendData(string); return self; }, $CharacterData_append$1.$$arity = 1); Opal.def(self, '$data', $CharacterData_data$2 = function $$data() { var self = this; return self["native"].data }, $CharacterData_data$2.$$arity = 0); Opal.def(self, '$delete', $CharacterData_delete$3 = function(count, offset) { var self = this; if (offset == null) { offset = 0; }; self["native"].deleteData(offset, count); return self; }, $CharacterData_delete$3.$$arity = -2); Opal.def(self, '$insert', $CharacterData_insert$4 = function $$insert(string, offset) { var self = this; if (offset == null) { offset = 0; }; self["native"].insertData(offset, string); return self; }, $CharacterData_insert$4.$$arity = -2); self.$alias_native("length"); Opal.def(self, '$replace', $CharacterData_replace$5 = function $$replace(string, offset, count) { var self = this; if (offset == null) { offset = 0; }; if (count == null) { count = self["native"].length; }; self["native"].replaceData(offset, count, string); return self; }, $CharacterData_replace$5.$$arity = -2); return (Opal.def(self, '$substring', $CharacterData_substring$6 = function $$substring(count, offset) { var self = this; if (offset == null) { offset = 0; }; return self["native"].substringData(offset, count); }, $CharacterData_substring$6.$$arity = -2), nil) && 'substring'; })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/text"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $gvars = Opal.gvars; Opal.add_stubs(['$create_text', '$DOM', '$data']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Text'); var $nesting = [self].concat($parent_nesting), $Text_create$1, $Text_whole$2, $Text_split$3, $Text_inspect$4; self.$$prototype["native"] = nil; Opal.defs(self, '$create', $Text_create$1 = function $$create($a) { var $post_args, args, self = this; if ($gvars.document == null) $gvars.document = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send($gvars.document, 'create_text', Opal.to_a(args)); }, $Text_create$1.$$arity = -1); Opal.def(self, '$whole', $Text_whole$2 = function $$whole() { var self = this; return self["native"].wholeText }, $Text_whole$2.$$arity = 0); Opal.def(self, '$split', $Text_split$3 = function $$split(offset) { var self = this; return self.$DOM(self["native"].splitText(offset)) }, $Text_split$3.$$arity = 1); return (Opal.def(self, '$inspect', $Text_inspect$4 = function $$inspect() { var self = this; return "" + "#" }, $Text_inspect$4.$$arity = 0), nil) && 'inspect'; })($nesting[0], $$($nesting, 'CharacterData'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/cdata"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$value']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'CDATA'); var $nesting = [self].concat($parent_nesting), $CDATA_inspect$1; return (Opal.def(self, '$inspect', $CDATA_inspect$1 = function $$inspect() { var self = this; return "" + "#" }, $CDATA_inspect$1.$$arity = 0), nil) && 'inspect' })($nesting[0], $$($nesting, 'Text'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/comment"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$value']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Comment'); var $nesting = [self].concat($parent_nesting), $Comment_inspect$1; return (Opal.def(self, '$inspect', $Comment_inspect$1 = function $$inspect() { var self = this; return "" + "#" }, $Comment_inspect$1.$$arity = 0), nil) && 'inspect' })($nesting[0], $$($nesting, 'CharacterData'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/attributes"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$to_n', '$[]', '$supports?', '$==', '$to_s', '$include', '$enum_for', '$each', '$attribute_nodes', '$name', '$value', '$!', '$[]=', '$-']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Attributes'); var $nesting = [self].concat($parent_nesting), $Attributes_initialize$1, $a, $Attributes_$$$2, $Attributes_$$$eq$3, $Attributes_$$$4, $Attributes_$$$eq$5, $Attributes_each$6, $Attributes_has_key$ques$8, $Attributes_merge$excl$9; self.$$prototype.namespace = self.$$prototype["native"] = self.$$prototype.element = nil; self.$attr_reader("namespace"); Opal.def(self, '$initialize', $Attributes_initialize$1 = function $$initialize(element, options) { var self = this; self.element = element; self["native"] = element.$to_n(); return (self.namespace = options['$[]']("namespace")); }, $Attributes_initialize$1.$$arity = 2); if ($truthy(($truthy($a = $$($nesting, 'Browser')['$supports?']("Element.className")) ? $a : $$($nesting, 'Browser')['$supports?']("Element.htmlFor")))) { Opal.def(self, '$[]', $Attributes_$$$2 = function(name, options) { var $a, self = this, namespace = nil; if (options == null) { options = $hash2([], {}); }; if ($truthy((($a = name['$==']("class")) ? $$($nesting, 'Browser')['$supports?']("Element.className") : name['$==']("class")))) { name = "className" } else if ($truthy((($a = name['$==']("for")) ? $$($nesting, 'Browser')['$supports?']("Element.htmlFor") : name['$==']("for")))) { name = "htmlFor"}; if ($truthy((namespace = ($truthy($a = options['$[]']("namespace")) ? $a : self.namespace)))) { return self["native"].getAttributeNS(namespace.$to_s(), name.$to_s()) || nil } else { return self["native"].getAttribute(name.$to_s()) || nil }; }, $Attributes_$$$2.$$arity = -2); Opal.def(self, '$[]=', $Attributes_$$$eq$3 = function(name, value, options) { var $a, self = this, namespace = nil; if (options == null) { options = $hash2([], {}); }; if ($truthy((($a = name['$==']("class")) ? $$($nesting, 'Browser')['$supports?']("Element.className") : name['$==']("class")))) { name = "className" } else if ($truthy((($a = name['$==']("for")) ? $$($nesting, 'Browser')['$supports?']("Element.htmlFor") : name['$==']("for")))) { name = "htmlFor"}; if ($truthy((namespace = ($truthy($a = options['$[]']("namespace")) ? $a : self.namespace)))) { return self["native"].setAttributeNS(namespace.$to_s(), name.$to_s(), value) } else { return self["native"].setAttribute(name.$to_s(), value.$to_s()) }; }, $Attributes_$$$eq$3.$$arity = -3); } else { Opal.def(self, '$[]', $Attributes_$$$4 = function(name, options) { var $a, self = this, namespace = nil; if (options == null) { options = $hash2([], {}); }; if ($truthy((namespace = ($truthy($a = options['$[]']("namespace")) ? $a : self.namespace)))) { return self["native"].getAttributeNS(namespace.$to_s(), name.$to_s()) || nil } else { return self["native"].getAttribute(name.$to_s()) || nil }; }, $Attributes_$$$4.$$arity = -2); Opal.def(self, '$[]=', $Attributes_$$$eq$5 = function(name, value, options) { var $a, self = this, namespace = nil; if (options == null) { options = $hash2([], {}); }; if ($truthy((namespace = ($truthy($a = options['$[]']("namespace")) ? $a : self.namespace)))) { return self["native"].setAttributeNS(namespace.$to_s(), name.$to_s(), value) } else { return self["native"].setAttribute(name.$to_s(), value.$to_s()) }; }, $Attributes_$$$eq$5.$$arity = -3); }; self.$include($$($nesting, 'Enumerable')); Opal.def(self, '$each', $Attributes_each$6 = function $$each() { var $iter = $Attributes_each$6.$$p, block = $iter || nil, $$7, self = this; if ($iter) $Attributes_each$6.$$p = null; if ($iter) $Attributes_each$6.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("each") }; $send(self.element.$attribute_nodes(), 'each', [], ($$7 = function(attr){var self = $$7.$$s || this; if (attr == null) { attr = nil; }; return Opal.yieldX(block, [attr.$name(), attr.$value()]);;}, $$7.$$s = self, $$7.$$arity = 1, $$7)); return self; }, $Attributes_each$6.$$arity = 0); Opal.alias(self, "get", "[]"); Opal.def(self, '$has_key?', $Attributes_has_key$ques$8 = function(name) { var self = this; return self['$[]'](name)['$!']()['$!']() }, $Attributes_has_key$ques$8.$$arity = 1); Opal.def(self, '$merge!', $Attributes_merge$excl$9 = function(hash) { var $$10, self = this; $send(hash, 'each', [], ($$10 = function(name, value){var self = $$10.$$s || this, $writer = nil; if (name == null) { name = nil; }; if (value == null) { value = nil; }; $writer = [name, value]; $send(self, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$10.$$s = self, $$10.$$arity = 2, $$10)); return self; }, $Attributes_merge$excl$9.$$arity = 1); return Opal.alias(self, "set", "[]="); })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/data"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $gvars = Opal.gvars; Opal.add_stubs(['$attr_reader', '$to_n', '$include', '$enum_for', '$call', '$each', '$attributes', '$=~', '$[]']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Data'); var $nesting = [self].concat($parent_nesting), $Data_initialize$1, $Data_each$2, $Data_assign$4, $Data_$$$6, $Data_$$$eq$7; self.$$prototype["native"] = self.$$prototype.element = nil; self.$attr_reader("element"); Opal.def(self, '$initialize', $Data_initialize$1 = function $$initialize(element) { var self = this; self.element = element; self["native"] = element.$to_n(); if ($truthy((typeof(self["native"].$data) !== "undefined"))) { return nil } else { return self["native"].$data = {} }; }, $Data_initialize$1.$$arity = 1); self.$include($$($nesting, 'Enumerable')); Opal.def(self, '$each', $Data_each$2 = function $$each() { var $iter = $Data_each$2.$$p, block = $iter || nil, $$3, self = this; if ($iter) $Data_each$2.$$p = null; if ($iter) $Data_each$2.$$p = null;; if ($truthy(block)) { } else { return self.$enum_for("each") }; var data = self["native"].$data; for (var key in data) { block.$call(key, data[key]); } ; $send(self.element.$attributes(), 'each', [], ($$3 = function(name, value){var self = $$3.$$s || this, $a; if (name == null) { name = nil; }; if (value == null) { value = nil; }; if ($truthy(name['$=~'](/^data-(.*)$/))) { return block.$call((($a = $gvars['~']) === nil ? nil : $a['$[]'](1)), value) } else { return nil };}, $$3.$$s = self, $$3.$$arity = 2, $$3)); return self; }, $Data_each$2.$$arity = 0); Opal.def(self, '$assign', $Data_assign$4 = function $$assign(data) { var $$5, self = this; $send(data, 'each', [], ($$5 = function(name, value){var self = $$5.$$s || this; if (self["native"] == null) self["native"] = nil; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return self["native"].$data[name] = value;}, $$5.$$s = self, $$5.$$arity = 2, $$5)); return self; }, $Data_assign$4.$$arity = 1); Opal.def(self, '$[]', $Data_$$$6 = function(name) { var self = this, data = nil; if ($truthy((data = self.element['$[]']("" + "data-" + (name))))) { return data}; var value = self["native"].$data[name]; if (value === undefined) { return nil; } else { return value; } ; }, $Data_$$$6.$$arity = 1); return (Opal.def(self, '$[]=', $Data_$$$eq$7 = function(name, value) { var self = this; return self["native"].$data[name] = value }, $Data_$$$eq$7.$$arity = 2), nil) && '[]='; })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/position"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$to_n', '$offset', '$get', '$parent', '$new', '$==', '$[]', '$style', '$=~', '$+', '$x', '$to_i', '$x=', '$-', '$y', '$y=']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Position'); var $nesting = [self].concat($parent_nesting), $Position_initialize$1, $Position_get$2, $Position_x$3, $Position_y$4; self.$$prototype.element = nil; self.$attr_reader("element"); Opal.def(self, '$initialize', $Position_initialize$1 = function $$initialize(element) { var self = this; self.element = element; return (self["native"] = element.$to_n()); }, $Position_initialize$1.$$arity = 1); Opal.def(self, '$get', $Position_get$2 = function $$get() { var self = this, offset = nil, position = nil, parent = nil, parent_offset = nil, $writer = nil; offset = self.element.$offset(); position = offset.$get(); parent = offset.$parent(); parent_offset = $$$($$($nesting, 'Browser'), 'Position').$new(0, 0); if (self.element.$style()['$[]']("position")['$==']("fixed")) { if ($truthy(parent['$=~']("html"))) { } else { parent_offset = parent.$offset() }; $writer = [$rb_plus(parent_offset.$x(), parent.$style()['$[]']("border-top-width").$to_i())]; $send(parent_offset, 'x=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; $writer = [$rb_plus(parent_offset.$y(), parent.$style()['$[]']("border-left-width").$to_i())]; $send(parent_offset, 'y=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];;}; return $$$($$($nesting, 'Browser'), 'Position').$new($rb_minus($rb_minus(position.$x(), parent_offset.$x()), self.element.$style()['$[]']("margin-left").$to_i()), $rb_minus($rb_minus(position.$y(), parent_offset.$y()), self.element.$style()['$[]']("margin-top").$to_i())); }, $Position_get$2.$$arity = 0); Opal.def(self, '$x', $Position_x$3 = function $$x() { var self = this; return self.$get().$x() }, $Position_x$3.$$arity = 0); return (Opal.def(self, '$y', $Position_y$4 = function $$y() { var self = this; return self.$get().$y() }, $Position_y$4.$$arity = 0), nil) && 'y'; })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/offset"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$to_n', '$DOM', '$root', '$document', '$x', '$get', '$set', '$y', '$supports?', '$window', '$new', '$[]', '$style!', '$==', '$[]=', '$style', '$-', '$to_u', '$===', '$first', '$+', '$px']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Offset'); var $nesting = [self].concat($parent_nesting), $Offset_initialize$1, $Offset_parent$2, $Offset_x$3, $Offset_x$eq$4, $Offset_y$5, $Offset_y$eq$6, $Offset_get$7, $Offset_get$8, $Offset_set$9; self.$$prototype["native"] = self.$$prototype.element = nil; self.$attr_reader("element"); Opal.def(self, '$initialize', $Offset_initialize$1 = function $$initialize(element) { var self = this; self.element = element; return (self["native"] = element.$to_n()); }, $Offset_initialize$1.$$arity = 1); Opal.def(self, '$parent', $Offset_parent$2 = function $$parent() { var self = this; return self.$DOM(self["native"].offsetParent || self.element.$document().$root().$to_n()) }, $Offset_parent$2.$$arity = 0); Opal.def(self, '$x', $Offset_x$3 = function $$x() { var self = this; return self.$get().$x() }, $Offset_x$3.$$arity = 0); Opal.def(self, '$x=', $Offset_x$eq$4 = function(value) { var self = this; return self.$set(value, nil) }, $Offset_x$eq$4.$$arity = 1); Opal.def(self, '$y', $Offset_y$5 = function $$y() { var self = this; return self.$get().$y() }, $Offset_y$5.$$arity = 0); Opal.def(self, '$y=', $Offset_y$eq$6 = function(value) { var self = this; return self.$set(nil, value) }, $Offset_y$eq$6.$$arity = 1); if ($truthy($$($nesting, 'Browser')['$supports?']("Element.getBoundingClientRect"))) { Opal.def(self, '$get', $Offset_get$7 = function $$get() { var self = this, doc = nil, root = nil, win = nil; doc = self.element.$document(); root = doc.$root().$to_n(); win = doc.$window().$to_n(); var box = self["native"].getBoundingClientRect(), y = box.top + (win.pageYOffset || root.scrollTop) - (root.clientTop || 0), x = box.left + (win.pageXOffset || root.scrollLeft) - (root.clientLeft || 0); ; return $$$($$($nesting, 'Browser'), 'Position').$new(x, y); }, $Offset_get$7.$$arity = 0) } else { Opal.def(self, '$get', $Offset_get$8 = function $$get() { var self = this, doc = nil, root = nil, win = nil; doc = self.$document(); root = doc.$root().$to_n(); win = doc.$window().$to_n(); var y = (win.pageYOffset || root.scrollTop) - (root.clientTop || 0), x = (win.pageXOffset || root.scrollLeft) - (root.clientLeft || 0); ; return $$$($$($nesting, 'Browser'), 'Position').$new(x, y); }, $Offset_get$8.$$arity = 0) }; return (Opal.def(self, '$set', $Offset_set$9 = function $$set($a) { var $post_args, value, $b, $c, self = this, position = nil, $writer = nil, offset = nil, top = nil, left = nil, x = nil, y = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); value = $post_args;; position = self.element['$style!']()['$[]']("position"); if (position['$==']("static")) { $writer = ["position", "relative"]; $send(self.element.$style(), '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];}; offset = self.$get(); top = self.element['$style!']()['$[]']("top").$to_u(); left = self.element['$style!']()['$[]']("left").$to_u(); if ($truthy($$$($$($nesting, 'Browser'), 'Position')['$==='](value.$first()))) { $b = [value.$first().$x(), value.$first().$y()], (x = $b[0]), (y = $b[1]), $b } else if ($truthy($$($nesting, 'Hash')['$==='](value.$first()))) { $b = [value.$first()['$[]']("x"), value.$first()['$[]']("y")], (x = $b[0]), (y = $b[1]), $b } else { $c = value, $b = Opal.to_ary($c), (x = ($b[0] == null ? nil : $b[0])), (y = ($b[1] == null ? nil : $b[1])), $c }; if ($truthy(x)) { $writer = ["left", $rb_plus($rb_minus(x.$px(), offset.$x()), left)]; $send(self.element.$style(), '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];}; if ($truthy(y)) { $writer = ["top", $rb_plus($rb_minus(y.$px(), offset.$y()), top)]; $send(self.element.$style(), '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; } else { return nil }; }, $Offset_set$9.$$arity = -1), nil) && 'set'; })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/scroll"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$attr_reader', '$to_n', '$supports?', '$===', '$first', '$[]', '$x', '$y', '$new', '$raise', '$position']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Scroll'); var $nesting = [self].concat($parent_nesting), $Scroll_initialize$1, $Scroll_to$2, $Scroll_position$3, $Scroll_to$4, $Scroll_position$5, $Scroll_to$6, $Scroll_position$7, $Scroll_x$8, $Scroll_y$9, $Scroll_height$10, $Scroll_width$11, $Scroll_by$12, $Scroll_to$13, $Scroll_to$14, $Scroll_to$excl$15; self.$$prototype["native"] = nil; self.$attr_reader("element"); Opal.def(self, '$initialize', $Scroll_initialize$1 = function $$initialize(element) { var self = this; self.element = element; return (self["native"] = element.$to_n()); }, $Scroll_initialize$1.$$arity = 1); if ($truthy($$($nesting, 'Browser')['$supports?']("Element.scroll"))) { Opal.def(self, '$to', $Scroll_to$2 = function $$to($a) { var $post_args, args, $b, $c, self = this, x = nil, y = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($$($nesting, 'Hash')['$==='](args.$first()))) { x = ($truthy($b = args.$first()['$[]']("x")) ? $b : self.$x()); y = ($truthy($b = args.$first()['$[]']("y")) ? $b : self.$y()); } else { $c = args, $b = Opal.to_ary($c), (x = ($b[0] == null ? nil : $b[0])), (y = ($b[1] == null ? nil : $b[1])), $c }; self["native"].scrollTop = y; return self["native"].scrollLeft = x; }, $Scroll_to$2.$$arity = -1); Opal.def(self, '$position', $Scroll_position$3 = function $$position() { var self = this; return $$$($$($nesting, 'Browser'), 'Position').$new(self["native"].scrollLeft, self["native"].scrollTop) }, $Scroll_position$3.$$arity = 0); } else if ($truthy($$($nesting, 'Browser')['$supports?']("Element.pageOffset"))) { Opal.def(self, '$to', $Scroll_to$4 = function $$to($a) { var $post_args, args, $b, $c, self = this, x = nil, y = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($$($nesting, 'Hash')['$==='](args.$first()))) { x = ($truthy($b = args.$first()['$[]']("x")) ? $b : self.$x()); y = ($truthy($b = args.$first()['$[]']("y")) ? $b : self.$y()); } else { $c = args, $b = Opal.to_ary($c), (x = ($b[0] == null ? nil : $b[0])), (y = ($b[1] == null ? nil : $b[1])), $c }; self["native"].pageYOffset = y; return self["native"].pageXOffset = x; }, $Scroll_to$4.$$arity = -1); Opal.def(self, '$position', $Scroll_position$5 = function $$position() { var self = this; return $$($nesting, 'Position').$new(self["native"].pageXOffset, self["native"].pageYOffset) }, $Scroll_position$5.$$arity = 0); } else { Opal.def(self, '$to', $Scroll_to$6 = function $$to($a) { var $post_args, args, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return self.$raise($$($nesting, 'NotImplementedError'), "scroll on element unsupported"); }, $Scroll_to$6.$$arity = -1); Opal.def(self, '$position', $Scroll_position$7 = function $$position() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "scroll on element unsupported") }, $Scroll_position$7.$$arity = 0); }; Opal.def(self, '$x', $Scroll_x$8 = function $$x() { var self = this; return self.$position().$x() }, $Scroll_x$8.$$arity = 0); Opal.def(self, '$y', $Scroll_y$9 = function $$y() { var self = this; return self.$position().$y() }, $Scroll_y$9.$$arity = 0); Opal.def(self, '$height', $Scroll_height$10 = function $$height() { var self = this; return self["native"].scrollHeight }, $Scroll_height$10.$$arity = 0); Opal.def(self, '$width', $Scroll_width$11 = function $$width() { var self = this; return self["native"].scrollWidth }, $Scroll_width$11.$$arity = 0); Opal.def(self, '$by', $Scroll_by$12 = function $$by($a) { var $post_args, args, $b, $c, self = this, x = nil, y = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy($$($nesting, 'Hash')['$==='](args.$first()))) { x = ($truthy($b = args.$first()['$[]']("x")) ? $b : 0); y = ($truthy($b = args.$first()['$[]']("y")) ? $b : 0); } else { $c = args, $b = Opal.to_ary($c), (x = ($b[0] == null ? nil : $b[0])), (y = ($b[1] == null ? nil : $b[1])), $c }; self["native"].scrollBy(x, y); return self; }, $Scroll_by$12.$$arity = -1); if ($truthy($$($nesting, 'Browser')['$supports?']("Element.scrollIntoViewIfNeeded"))) { Opal.def(self, '$to', $Scroll_to$13 = function $$to(align) { var self = this; if (align == null) { align = true; }; return self["native"].scrollIntoViewIfNeeded(align); }, $Scroll_to$13.$$arity = -1) } else { Opal.def(self, '$to', $Scroll_to$14 = function $$to(align) { var self = this; if (align == null) { align = true; }; return self.$raise($$($nesting, 'NotImplementedError')); }, $Scroll_to$14.$$arity = -1) }; return (Opal.def(self, '$to!', $Scroll_to$excl$15 = function(align) { var self = this; if (align == null) { align = true; }; return self["native"].scrollIntoView(align); }, $Scroll_to$excl$15.$$arity = -1), nil) && 'to!'; })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/size"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$attr_reader', '$to_n', '$[]=', '$style', '$-']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Size'); var $nesting = [self].concat($parent_nesting), $Size_initialize$1, $Size_width$2, $Size_width$eq$3, $Size_height$4, $Size_height$eq$5; self.$$prototype["native"] = self.$$prototype.element = nil; self.$attr_reader("element"); Opal.def(self, '$initialize', $Size_initialize$1 = function $$initialize(element, $a) { var $post_args, inc, self = this; $post_args = Opal.slice.call(arguments, 1, arguments.length); inc = $post_args;; self.element = element; self["native"] = element.$to_n(); return (self.include = inc); }, $Size_initialize$1.$$arity = -2); Opal.def(self, '$width', $Size_width$2 = function $$width() { var self = this; return self["native"].offsetWidth }, $Size_width$2.$$arity = 0); Opal.def(self, '$width=', $Size_width$eq$3 = function(value) { var self = this, $writer = nil; $writer = ["width", value]; $send(self.element.$style(), '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; }, $Size_width$eq$3.$$arity = 1); Opal.def(self, '$height', $Size_height$4 = function $$height() { var self = this; return self["native"].offsetHeight }, $Size_height$4.$$arity = 0); return (Opal.def(self, '$height=', $Size_height$eq$5 = function(value) { var self = this, $writer = nil; $writer = ["height", value]; $send(self.element.$style(), '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; }, $Size_height$eq$5.$$arity = 1), nil) && 'height='; })($nesting[0], null, $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/input"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Input'); var $nesting = [self].concat($parent_nesting), $Input_value$1, $Input_value$eq$2, $Input_checked$ques$3, $Input_clear$4; self.$$prototype["native"] = nil; Opal.def(self, '$value', $Input_value$1 = function $$value() { var self = this; if (self["native"].value == "") { return nil; } else { return self["native"].value; } }, $Input_value$1.$$arity = 0); Opal.def(self, '$value=', $Input_value$eq$2 = function(value) { var self = this; return self["native"].value = value }, $Input_value$eq$2.$$arity = 1); Opal.def(self, '$checked?', $Input_checked$ques$3 = function() { var self = this; return self["native"].checked }, $Input_checked$ques$3.$$arity = 0); return (Opal.def(self, '$clear', $Input_clear$4 = function $$clear() { var self = this; return self["native"].value = '' }, $Input_clear$4.$$arity = 0), nil) && 'clear'; })($nesting[0], $$($nesting, 'Element'), $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/select"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$[]', '$new', '$DOM', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Select'); var $nesting = [self].concat($parent_nesting), $Select_value$1, $Select_labels$2, $Select_options$3, $Select_option$4, $Select_index$5; self.$$prototype["native"] = nil; Opal.def(self, '$value', $Select_value$1 = function $$value() { var self = this; if (self["native"].value == "") { return nil; } else { return self["native"].value; } }, $Select_value$1.$$arity = 0); Opal.def(self, '$labels', $Select_labels$2 = function $$labels() { var self = this; return $$($nesting, 'NodeSet')['$[]']($$$($$($nesting, 'Native'), 'Array').$new(self["native"].labels)) }, $Select_labels$2.$$arity = 0); Opal.def(self, '$options', $Select_options$3 = function $$options() { var self = this; return $$($nesting, 'NodeSet')['$[]']($$$($$($nesting, 'Native'), 'Array').$new(self["native"].options)) }, $Select_options$3.$$arity = 0); Opal.def(self, '$option', $Select_option$4 = function $$option() { var self = this; return self.$DOM(self["native"].options[self["native"].selectedIndex]) }, $Select_option$4.$$arity = 0); Opal.def(self, '$index', $Select_index$5 = function $$index() { var self = this; return self["native"].selectedIndex }, $Select_index$5.$$arity = 0); self.$alias_native("multiple?", "multiple"); self.$alias_native("required?", "required"); return self.$alias_native("length"); })($nesting[0], $$($nesting, 'Element'), $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/image"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Image'); var $nesting = [self].concat($parent_nesting), $Image_complete$ques$1, $Image_cross$ques$2, $Image_height$3, $Image_width$4; self.$$prototype["native"] = nil; Opal.def(self, '$complete?', $Image_complete$ques$1 = function() { var self = this; return self["native"].complete }, $Image_complete$ques$1.$$arity = 0); Opal.def(self, '$cross?', $Image_cross$ques$2 = function() { var self = this; return self["native"].crossOrigin }, $Image_cross$ques$2.$$arity = 0); Opal.def(self, '$height', $Image_height$3 = function $$height() { var self = this; return self["native"].naturalHeight }, $Image_height$3.$$arity = 0); return (Opal.def(self, '$width', $Image_width$4 = function $$width() { var self = this; return self["native"].naturalWidth }, $Image_width$4.$$arity = 0), nil) && 'width'; })($nesting[0], $$($nesting, 'Element'), $nesting); return Opal.const_set($nesting[0], 'Img', $$($nesting, 'Image')); })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/template"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; Opal.add_stubs(['$DOM']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Template'); var $nesting = [self].concat($parent_nesting), $Template_content$1; self.$$prototype["native"] = nil; return (Opal.def(self, '$content', $Template_content$1 = function $$content() { var self = this; return self.$DOM(self["native"].content) }, $Template_content$1.$$arity = 0), nil) && 'content' })($nesting[0], $$($nesting, 'Element'), $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element/textarea"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Textarea'); var $nesting = [self].concat($parent_nesting), $Textarea_value$1, $Textarea_value$eq$2, $Textarea_clear$3; self.$$prototype["native"] = nil; Opal.def(self, '$value', $Textarea_value$1 = function $$value() { var self = this; if (self["native"].value == "") { return nil; } else { return self["native"].value; } }, $Textarea_value$1.$$arity = 0); Opal.def(self, '$value=', $Textarea_value$eq$2 = function(value) { var self = this; return self["native"].value = value }, $Textarea_value$eq$2.$$arity = 1); return (Opal.def(self, '$clear', $Textarea_clear$3 = function $$clear() { var self = this; return self["native"].value = '' }, $Textarea_clear$3.$$arity = 0), nil) && 'clear'; })($nesting[0], $$($nesting, 'Element'), $nesting) })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/element"] = function(Opal) { function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send, $gvars = Opal.gvars, $truthy = Opal.truthy, $hash2 = Opal.hash2; Opal.add_stubs(['$require', '$create_element', '$==', '$capitalize', '$include?', '$constants', '$new', '$const_get', '$include', '$target', '$DOM', '$supports?', '$loaded?', '$raise', '$[]', '$map', '$xpath', '$get', '$attributes', '$set', '$+', '$class_names', '$empty?', '$join', '$uniq', '$first', '$css', '$each', '$alias_native', '$reject', '$split', '$to_proc', '$===', '$assign', '$height', '$size', '$height=', '$-', '$to_s', '$clear', '$document', '$<<', '$to_a', '$downcase', '$name', '$id', '$offset', '$flatten', '$concat', '$replace', '$apply', '$to_n', '$window', '$width', '$width=']); self.$require("browser/dom/element/attributes"); self.$require("browser/dom/element/data"); self.$require("browser/dom/element/position"); self.$require("browser/dom/element/offset"); self.$require("browser/dom/element/scroll"); self.$require("browser/dom/element/size"); self.$require("browser/dom/element/input"); self.$require("browser/dom/element/select"); self.$require("browser/dom/element/image"); self.$require("browser/dom/element/template"); self.$require("browser/dom/element/textarea"); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting), $Element_create$1, $Element_new$2, $Element$3, $Element_$eq_tilde$4, $Element_$eq_tilde$5, $Element_$eq_tilde$6, $Element_$eq_tilde$7, $Element_$eq_tilde$8, $Element_$eq_tilde$9, $Element_$eq_tilde$10, $Element_$slash$11, $Element_$$$13, $Element_$$$eq$14, $Element_add_class$15, $Element_at$16, $Element_at_css$17, $Element_at_xpath$19, $Element_attributes$21, $Element_attribute_nodes$22, $Element_class_names$23, $Element_css$24, $Element_css$25, $Element_css$26, $Element_data$27, $Element_height$28, $Element_height$eq$29, $Element_id$30, $Element_id$eq$31, $Element_inner_dom$32, $Element_inner_dom$eq$33, $Element_inspect$34, $Element_offset$35, $Element_offset$eq$36, $Element_position$37, $Element_scroll$38, $Element_search$39, $Element_style$41, $Element_style$excl$42, $Element_style$excl$43, $Element_style$excl$44, $Element_remove_attribute$45, $Element_remove_class$46, $Element_size$47, $Element_width$48, $Element_width$eq$49, $Element_window$50, $a, $Element_xpath$51, $Element_xpath$52; self.$$prototype["native"] = nil; Opal.defs(self, '$create', $Element_create$1 = function $$create($a) { var $post_args, args, self = this; if ($gvars.document == null) $gvars.document = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send($gvars.document, 'create_element', Opal.to_a(args)); }, $Element_create$1.$$arity = -1); Opal.defs(self, '$new', $Element_new$2 = function(node) { var $iter = $Element_new$2.$$p, $yield = $iter || nil, self = this, name = nil, $zuper = nil, $zuper_i = nil, $zuper_ii = nil; if ($iter) $Element_new$2.$$p = null; // Prepare super implicit arguments for($zuper_i = 0, $zuper_ii = arguments.length, $zuper = new Array($zuper_ii); $zuper_i < $zuper_ii; $zuper_i++) { $zuper[$zuper_i] = arguments[$zuper_i]; } if (self['$==']($$($nesting, 'Element'))) { name = (node.nodeName).$capitalize(); if ($truthy($$($nesting, 'Element').$constants()['$include?'](name))) { return $$($nesting, 'Element').$const_get(name).$new(node) } else { return $send(self, Opal.find_super_dispatcher(self, 'new', $Element_new$2, false, self.$$class.$$prototype), $zuper, $iter) }; } else { return $send(self, Opal.find_super_dispatcher(self, 'new', $Element_new$2, false, self.$$class.$$prototype), $zuper, $iter) } }, $Element_new$2.$$arity = 1); self.$include($$$($$($nesting, 'Event'), 'Target')); $send(self, 'target', [], ($Element$3 = function(value){var self = $Element$3.$$s || this; if (value == null) { value = nil; }; try { return self.$DOM(value) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return nil } finally { Opal.pop_exception() } } else { throw $err; } };}, $Element$3.$$s = self, $Element$3.$$arity = 1, $Element$3)); if ($truthy($$($nesting, 'Browser')['$supports?']("Element.matches"))) { Opal.def(self, '$=~', $Element_$eq_tilde$4 = function(selector) { var self = this; return self["native"].matches(selector) }, $Element_$eq_tilde$4.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Element.matches (Opera)"))) { Opal.def(self, '$=~', $Element_$eq_tilde$5 = function(selector) { var self = this; return self["native"].oMatchesSelector(selector) }, $Element_$eq_tilde$5.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Element.matches (Internet Explorer)"))) { Opal.def(self, '$=~', $Element_$eq_tilde$6 = function(selector) { var self = this; return self["native"].msMatchesSelector(selector) }, $Element_$eq_tilde$6.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Element.matches (Firefox)"))) { Opal.def(self, '$=~', $Element_$eq_tilde$7 = function(selector) { var self = this; return self["native"].mozMatchesSelector(selector) }, $Element_$eq_tilde$7.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Element.matches (Chrome)"))) { Opal.def(self, '$=~', $Element_$eq_tilde$8 = function(selector) { var self = this; return self["native"].webkitMatchesSelector(selector) }, $Element_$eq_tilde$8.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$loaded?']("Sizzle"))) { Opal.def(self, '$=~', $Element_$eq_tilde$9 = function(selector) { var self = this; return Sizzle.matchesSelector(self["native"], selector) }, $Element_$eq_tilde$9.$$arity = 1) } else { Opal.def(self, '$=~', $Element_$eq_tilde$10 = function(selector) { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "selector matching unsupported") }, $Element_$eq_tilde$10.$$arity = 1) }; Opal.def(self, '$/', $Element_$slash$11 = function($a) { var $post_args, paths, $$12, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); paths = $post_args;; return $$($nesting, 'NodeSet')['$[]']($send(paths, 'map', [], ($$12 = function(path){var self = $$12.$$s || this; if (path == null) { path = nil; }; return self.$xpath(path);}, $$12.$$s = self, $$12.$$arity = 1, $$12))); }, $Element_$slash$11.$$arity = -1); Opal.def(self, '$[]', $Element_$$$13 = function(name, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return self.$attributes().$get(name, options); }, $Element_$$$13.$$arity = -2); Opal.def(self, '$[]=', $Element_$$$eq$14 = function(name, value, options) { var self = this; if (options == null) { options = $hash2([], {}); }; return self.$attributes().$set(name, value, options); }, $Element_$$$eq$14.$$arity = -3); Opal.def(self, '$add_class', $Element_add_class$15 = function $$add_class($a) { var $post_args, names, self = this, classes = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; classes = $rb_plus(self.$class_names(), names); if ($truthy(classes['$empty?']())) { } else { self["native"].className = classes.$uniq().$join(" ") }; return self; }, $Element_add_class$15.$$arity = -1); Opal.def(self, '$at', $Element_at$16 = function $$at(path_or_selector) { var $a, self = this; return ($truthy($a = self.$xpath(path_or_selector).$first()) ? $a : self.$css(path_or_selector).$first()) }, $Element_at$16.$$arity = 1); Opal.def(self, '$at_css', $Element_at_css$17 = function $$at_css($a) { var $post_args, rules, $$18, self = this, result = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); rules = $post_args;; result = nil; (function(){var $brk = Opal.new_brk(); try {return $send(rules, 'each', [], ($$18 = function(rule){var self = $$18.$$s || this; if (rule == null) { rule = nil; }; if ($truthy((result = self.$css(rule).$first()))) { Opal.brk(nil, $brk) } else { return nil };}, $$18.$$s = self, $$18.$$brk = $brk, $$18.$$arity = 1, $$18)) } catch (err) { if (err === $brk) { return err.$v } else { throw err } }})(); return result; }, $Element_at_css$17.$$arity = -1); Opal.def(self, '$at_xpath', $Element_at_xpath$19 = function $$at_xpath($a) { var $post_args, paths, $$20, self = this, result = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); paths = $post_args;; result = nil; (function(){var $brk = Opal.new_brk(); try {return $send(paths, 'each', [], ($$20 = function(path){var self = $$20.$$s || this; if (path == null) { path = nil; }; if ($truthy((result = self.$xpath(path).$first()))) { Opal.brk(nil, $brk) } else { return nil };}, $$20.$$s = self, $$20.$$brk = $brk, $$20.$$arity = 1, $$20)) } catch (err) { if (err === $brk) { return err.$v } else { throw err } }})(); return result; }, $Element_at_xpath$19.$$arity = -1); Opal.alias(self, "attr", "[]"); Opal.alias(self, "attribute", "[]"); Opal.def(self, '$attributes', $Element_attributes$21 = function $$attributes(options) { var self = this; if (options == null) { options = $hash2([], {}); }; return $$($nesting, 'Attributes').$new(self, options); }, $Element_attributes$21.$$arity = -1); Opal.def(self, '$attribute_nodes', $Element_attribute_nodes$22 = function $$attribute_nodes() { var self = this; return $$($nesting, 'NodeSet')['$[]']($$$($$($nesting, 'Native'), 'Array').$new(self["native"].attributes, $hash2(["get"], {"get": "item"}))) }, $Element_attribute_nodes$22.$$arity = 0); self.$alias_native("class_name", "className"); Opal.def(self, '$class_names', $Element_class_names$23 = function $$class_names() { var self = this; return $send((self["native"].className).$split(/\s+/), 'reject', [], "empty?".$to_proc()) }, $Element_class_names$23.$$arity = 0); if ($truthy($$($nesting, 'Browser')['$supports?']("Query.css"))) { Opal.def(self, '$css', $Element_css$24 = function $$css(path) { var self = this; try { return $$($nesting, 'NodeSet')['$[]']($$$($$($nesting, 'Native'), 'Array').$new(self["native"].querySelectorAll(path))) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return $$($nesting, 'NodeSet')['$[]']() } finally { Opal.pop_exception() } } else { throw $err; } } }, $Element_css$24.$$arity = 1) } else if ($truthy($$($nesting, 'Browser')['$loaded?']("Sizzle"))) { Opal.def(self, '$css', $Element_css$25 = function $$css(path) { var self = this; try { return $$($nesting, 'NodeSet')['$[]'](Sizzle(path, self["native"])) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return $$($nesting, 'NodeSet')['$[]']() } finally { Opal.pop_exception() } } else { throw $err; } } }, $Element_css$25.$$arity = 1) } else { Opal.def(self, '$css', $Element_css$26 = function $$css(selector) { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "query by CSS selector unsupported") }, $Element_css$26.$$arity = 1) }; Opal.def(self, '$data', $Element_data$27 = function $$data(value) { var self = this, data = nil; if (value == null) { value = nil; }; data = $$($nesting, 'Data').$new(self); if ($truthy(value)) { } else { return data }; if ($truthy($$($nesting, 'Hash')['$==='](value))) { data.$assign(value) } else { self.$raise($$($nesting, 'ArgumentError'), "unknown data type") }; return self; }, $Element_data$27.$$arity = -1); Opal.alias(self, "get_attribute", "[]"); Opal.alias(self, "get", "[]"); Opal.def(self, '$height', $Element_height$28 = function $$height() { var self = this; return self.$size().$height() }, $Element_height$28.$$arity = 0); Opal.def(self, '$height=', $Element_height$eq$29 = function(value) { var self = this, $writer = nil; $writer = [value]; $send(self.$size(), 'height=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; }, $Element_height$eq$29.$$arity = 1); Opal.def(self, '$id', $Element_id$30 = function $$id() { var self = this; var id = self["native"].id; if (id === "") { return nil; } else { return id; } }, $Element_id$30.$$arity = 0); Opal.def(self, '$id=', $Element_id$eq$31 = function(value) { var self = this; return self["native"].id = value.$to_s() }, $Element_id$eq$31.$$arity = 1); Opal.def(self, '$inner_dom', $Element_inner_dom$32 = function $$inner_dom() { var $iter = $Element_inner_dom$32.$$p, block = $iter || nil, self = this, doc = nil; if ($iter) $Element_inner_dom$32.$$p = null; if ($iter) $Element_inner_dom$32.$$p = null;; self.$clear(); doc = self.$document(); return self['$<<']($send($$($nesting, 'Builder'), 'new', [doc, self], block.$to_proc()).$to_a()); }, $Element_inner_dom$32.$$arity = 0); Opal.def(self, '$inner_dom=', $Element_inner_dom$eq$33 = function(node) { var self = this; self.$clear(); return self['$<<'](node); }, $Element_inner_dom$eq$33.$$arity = 1); Opal.def(self, '$inspect', $Element_inspect$34 = function $$inspect() { var self = this, inspect = nil; inspect = self.$name().$downcase(); if ($truthy(self.$id())) { inspect = $rb_plus(inspect, $rb_plus($rb_plus(".", self.$id()), "!"))}; if ($truthy(self.$class_names()['$empty?']())) { } else { inspect = $rb_plus(inspect, $rb_plus(".", self.$class_names().$join("."))) }; return "" + "#"; }, $Element_inspect$34.$$arity = 0); Opal.def(self, '$offset', $Element_offset$35 = function $$offset($a) { var $post_args, values, self = this, off = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); values = $post_args;; off = $$($nesting, 'Offset').$new(self); if ($truthy(values['$empty?']())) { } else { $send(off, 'set', Opal.to_a(values)) }; return off; }, $Element_offset$35.$$arity = -1); Opal.def(self, '$offset=', $Element_offset$eq$36 = function(value) { var self = this; return $send(self.$offset(), 'set', Opal.to_a(value)) }, $Element_offset$eq$36.$$arity = 1); Opal.def(self, '$position', $Element_position$37 = function $$position() { var self = this; return $$($nesting, 'Position').$new(self) }, $Element_position$37.$$arity = 0); Opal.def(self, '$scroll', $Element_scroll$38 = function $$scroll() { var self = this; return $$($nesting, 'Scroll').$new(self) }, $Element_scroll$38.$$arity = 0); Opal.def(self, '$search', $Element_search$39 = function $$search($a) { var $post_args, selectors, $$40, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); selectors = $post_args;; return $$($nesting, 'NodeSet').$new($send(selectors, 'map', [], ($$40 = function(selector){var self = $$40.$$s || this; if (selector == null) { selector = nil; }; return self.$xpath(selector).$to_a().$concat(self.$css(selector).$to_a());}, $$40.$$s = self, $$40.$$arity = 1, $$40)).$flatten().$uniq()); }, $Element_search$39.$$arity = -1); Opal.alias(self, "set", "[]="); Opal.alias(self, "set_attribute", "[]="); Opal.def(self, '$style', $Element_style$41 = function $$style(data) { var $iter = $Element_style$41.$$p, block = $iter || nil, $a, self = this, style = nil; if ($iter) $Element_style$41.$$p = null; if ($iter) $Element_style$41.$$p = null;; if (data == null) { data = nil; }; style = $$$($$($nesting, 'CSS'), 'Declaration').$new(self["native"].style); if ($truthy(($truthy($a = data) ? $a : block))) { } else { return style }; if ($truthy($$($nesting, 'String')['$==='](data))) { style.$replace(data) } else if ($truthy($$($nesting, 'Hash')['$==='](data))) { style.$assign(data) } else if ($truthy(block)) { $send(style, 'apply', [], block.$to_proc()) } else { self.$raise($$($nesting, 'ArgumentError'), "unknown data type") }; return self; }, $Element_style$41.$$arity = -1); if ($truthy($$($nesting, 'Browser')['$supports?']("CSS.computed"))) { Opal.def(self, '$style!', $Element_style$excl$42 = function() { var self = this; return $$$($$($nesting, 'CSS'), 'Declaration').$new(self.$window().$to_n().getComputedStyle(self["native"], null)) }, $Element_style$excl$42.$$arity = 0) } else if ($truthy($$($nesting, 'Browser')['$supports?']("CSS.current"))) { Opal.def(self, '$style!', $Element_style$excl$43 = function() { var self = this; return $$$($$($nesting, 'CSS'), 'Declaration').$new(self["native"].currentStyle) }, $Element_style$excl$43.$$arity = 0) } else { Opal.def(self, '$style!', $Element_style$excl$44 = function() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "computed style unsupported") }, $Element_style$excl$44.$$arity = 0) }; Opal.def(self, '$remove_attribute', $Element_remove_attribute$45 = function $$remove_attribute(name) { var self = this; return self["native"].removeAttribute(name) }, $Element_remove_attribute$45.$$arity = 1); Opal.def(self, '$remove_class', $Element_remove_class$46 = function $$remove_class($a) { var $post_args, names, self = this, classes = nil; $post_args = Opal.slice.call(arguments, 0, arguments.length); names = $post_args;; classes = $rb_minus(self.$class_names(), names); if ($truthy(classes['$empty?']())) { self["native"].removeAttribute('class') } else { self["native"].className = classes.$join(" ") }; return self; }, $Element_remove_class$46.$$arity = -1); Opal.def(self, '$size', $Element_size$47 = function $$size($a) { var $post_args, inc, self = this; $post_args = Opal.slice.call(arguments, 0, arguments.length); inc = $post_args;; return $send($$($nesting, 'Size'), 'new', [self].concat(Opal.to_a(inc))); }, $Element_size$47.$$arity = -1); Opal.def(self, '$width', $Element_width$48 = function $$width() { var self = this; return self.$size().$width() }, $Element_width$48.$$arity = 0); Opal.def(self, '$width=', $Element_width$eq$49 = function(value) { var self = this, $writer = nil; $writer = [value]; $send(self.$size(), 'width=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; }, $Element_width$eq$49.$$arity = 1); Opal.def(self, '$window', $Element_window$50 = function $$window() { var self = this; return self.$document().$window() }, $Element_window$50.$$arity = 0); if ($truthy(($truthy($a = $$($nesting, 'Browser')['$supports?']("Query.xpath")) ? $a : $$($nesting, 'Browser')['$loaded?']("wicked-good-xpath")))) { if ($truthy($$($nesting, 'Browser')['$loaded?']("wicked-good-xpath"))) { wgxpath.install()}; return (Opal.def(self, '$xpath', $Element_xpath$51 = function $$xpath(path) { var self = this; try { return $$($nesting, 'NodeSet')['$[]']($$$($$($nesting, 'Native'), 'Array').$new((self["native"].ownerDocument || self["native"]).evaluate(path, self["native"], null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), $hash2(["get", "length"], {"get": "snapshotItem", "length": "snapshotLength"}))) } catch ($err) { if (Opal.rescue($err, [$$($nesting, 'StandardError')])) { try { return $$($nesting, 'NodeSet')['$[]']() } finally { Opal.pop_exception() } } else { throw $err; } } }, $Element_xpath$51.$$arity = 1), nil) && 'xpath'; } else { return (Opal.def(self, '$xpath', $Element_xpath$52 = function $$xpath(path) { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "query by XPath unsupported") }, $Element_xpath$52.$$arity = 1), nil) && 'xpath' }; })($nesting[0], $$($nesting, 'Node'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/document"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2, $send = Opal.send; Opal.add_stubs(['$DOM', '$first', '$css', '$xpath', '$[]', '$supports?', '$raise', '$ready?', '$call', '$on', '$off', '$convert', '$new']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Document'); var $nesting = [self].concat($parent_nesting), $Document_$$$1, $Document_body$2, $Document_create_element$3, $Document_create_text$4, $Document_document$5, $Document_head$6, $Document_inspect$7, $Document_ready$8, $Document_ready$10, $Document_ready$12, $Document_ready$ques$13, $Document_root$14, $Document_root$eq$15, $Document_style_sheets$16, $Document_title$18, $Document_title$eq$19, $Document_window$20, $Document_window$21, $Document_window$22; self.$$prototype["native"] = nil; Opal.def(self, '$[]', $Document_$$$1 = function(what) { var $a, self = this; var result = self["native"].getElementById(what); if (result) { return self.$DOM(result); } ; return ($truthy($a = self.$css(what).$first()) ? $a : self.$xpath(what).$first()); }, $Document_$$$1.$$arity = 1); Opal.alias(self, "at", "[]"); Opal.def(self, '$body', $Document_body$2 = function $$body() { var self = this; return self.$DOM(self["native"].body) }, $Document_body$2.$$arity = 0); Opal.def(self, '$create_element', $Document_create_element$3 = function $$create_element(name, options) { var self = this, ns = nil; if (options == null) { options = $hash2([], {}); }; if ($truthy((ns = options['$[]']("namespace")))) { return self.$DOM(self["native"].createElementNS(ns, name)) } else { return self.$DOM(self["native"].createElement(name)) }; }, $Document_create_element$3.$$arity = -2); Opal.def(self, '$create_text', $Document_create_text$4 = function $$create_text(content) { var self = this; return self.$DOM(self["native"].createTextNode(content)) }, $Document_create_text$4.$$arity = 1); Opal.def(self, '$document', $Document_document$5 = function $$document() { var self = this; return self }, $Document_document$5.$$arity = 0); Opal.def(self, '$head', $Document_head$6 = function $$head() { var self = this; return self.$DOM(self["native"].getElementsByTagName("head")[0]) }, $Document_head$6.$$arity = 0); Opal.def(self, '$inspect', $Document_inspect$7 = function $$inspect() { var self = this; return "#" }, $Document_inspect$7.$$arity = 0); if ($truthy($$($nesting, 'Browser')['$supports?']("Event.addListener"))) { Opal.def(self, '$ready', $Document_ready$8 = function $$ready() { var $iter = $Document_ready$8.$$p, block = $iter || nil, $$9, self = this; if ($iter) $Document_ready$8.$$p = null; if ($iter) $Document_ready$8.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "no block given") }; if ($truthy(self['$ready?']())) { return block.$call()}; return $send(self, 'on', ["dom:load"], ($$9 = function(e){var self = $$9.$$s || this; if (e == null) { e = nil; }; e.$off(); return block.$call();}, $$9.$$s = self, $$9.$$arity = 1, $$9)); }, $Document_ready$8.$$arity = 0) } else if ($truthy($$($nesting, 'Browser')['$supports?']("Event.attach"))) { Opal.def(self, '$ready', $Document_ready$10 = function $$ready() { var $iter = $Document_ready$10.$$p, block = $iter || nil, $$11, self = this; if ($iter) $Document_ready$10.$$p = null; if ($iter) $Document_ready$10.$$p = null;; if ($truthy(block)) { } else { self.$raise($$($nesting, 'ArgumentError'), "no block given") }; if ($truthy(self['$ready?']())) { return block.$call()}; return $send(self, 'on', ["ready:state:change"], ($$11 = function(e){var self = $$11.$$s || this; if (e == null) { e = nil; }; if ($truthy(self['$ready?']())) { e.$off(); return block.$call(); } else { return nil };}, $$11.$$s = self, $$11.$$arity = 1, $$11)); }, $Document_ready$10.$$arity = 0) } else { Opal.def(self, '$ready', $Document_ready$12 = function $$ready() { var $iter = $Document_ready$12.$$p, block = $iter || nil, self = this; if ($iter) $Document_ready$12.$$p = null; if ($iter) $Document_ready$12.$$p = null;; return self.$raise($$($nesting, 'NotImplementedError'), "document ready unsupported"); }, $Document_ready$12.$$arity = 0) }; Opal.def(self, '$ready?', $Document_ready$ques$13 = function() { var self = this; return self["native"].readyState === "complete" }, $Document_ready$ques$13.$$arity = 0); Opal.def(self, '$root', $Document_root$14 = function $$root() { var self = this; return self.$DOM(self["native"].documentElement) }, $Document_root$14.$$arity = 0); Opal.def(self, '$root=', $Document_root$eq$15 = function(element) { var self = this; return self["native"].documentElement = $$($nesting, 'Native').$convert(element) }, $Document_root$eq$15.$$arity = 1); Opal.def(self, '$style_sheets', $Document_style_sheets$16 = function $$style_sheets() { var $$17, self = this; return $send($$$($$($nesting, 'Native'), 'Array'), 'new', [self["native"].styleSheets], ($$17 = function(e){var self = $$17.$$s || this; if (e == null) { e = nil; }; return $$$($$($nesting, 'CSS'), 'StyleSheet').$new(e);}, $$17.$$s = self, $$17.$$arity = 1, $$17)) }, $Document_style_sheets$16.$$arity = 0); Opal.def(self, '$title', $Document_title$18 = function $$title() { var self = this; return self["native"].title }, $Document_title$18.$$arity = 0); Opal.def(self, '$title=', $Document_title$eq$19 = function(value) { var self = this; return self["native"].title = value }, $Document_title$eq$19.$$arity = 1); if ($truthy($$($nesting, 'Browser')['$supports?']("Document.view"))) { return (Opal.def(self, '$window', $Document_window$20 = function $$window() { var self = this; return $$($nesting, 'Window').$new(self["native"].defaultView) }, $Document_window$20.$$arity = 0), nil) && 'window' } else if ($truthy($$($nesting, 'Browser')['$supports?']("Document.window"))) { return (Opal.def(self, '$window', $Document_window$21 = function $$window() { var self = this; return $$($nesting, 'Window').$new(self["native"].parentWindow) }, $Document_window$21.$$arity = 0), nil) && 'window' } else { return (Opal.def(self, '$window', $Document_window$22 = function $$window() { var self = this; return self.$raise($$($nesting, 'NotImplementedError'), "window from document unsupported") }, $Document_window$22.$$arity = 0), nil) && 'window' }; })($nesting[0], $$($nesting, 'Element'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/document_fragment"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass; return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'DocumentFragment'); var $nesting = [self].concat($parent_nesting); return nil })($nesting[0], $$($nesting, 'Element'), $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/builder"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $hash2 = Opal.hash2, $send = Opal.send; Opal.add_stubs(['$<<', '$[]=', '$to_h', '$-', '$[]', '$each', '$===', '$call', '$raise', '$attr_reader', '$new', '$to_proc', '$map', '$build', '$for', '$create_text', '$document', '$create_element', '$merge!', '$attributes', '$add_class', '$on', '$inner_html=']); (function($base, $parent_nesting) { var self = $module($base, 'Utils'); var $nesting = [self].concat($parent_nesting), $Utils_heredoc$1; Opal.defs(self, '$heredoc', $Utils_heredoc$1 = function $$heredoc(string) { var self = this; return string }, $Utils_heredoc$1.$$arity = 1) })($$($nesting, 'Paggio'), $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Element'); var $nesting = [self].concat($parent_nesting), $Element_on$2; self.$$prototype.on = nil; return (Opal.def(self, '$on', $Element_on$2 = function $$on($a) { var $iter = $Element_on$2.$$p, block = $iter || nil, $post_args, args, $b, self = this; if ($iter) $Element_on$2.$$p = null; if ($iter) $Element_on$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return (self.on = ($truthy($b = self.on) ? $b : []))['$<<']([args, block]); }, $Element_on$2.$$arity = -1), nil) && 'on' })($$$($$($nesting, 'Paggio'), 'HTML'), $$($nesting, 'BasicObject'), $nesting); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting), $DOM$10, $DOM$11, $DOM$15; (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Builder'); var $nesting = [self].concat($parent_nesting), $Builder_to_h$3, $Builder_for$4, $Builder_build$5, $Builder_initialize$7, $Builder_to_a$9; self.$$prototype.builder = self.$$prototype.roots = nil; Opal.defs(self, '$to_h', $Builder_to_h$3 = function $$to_h() { var $a, self = this; if (self.builders == null) self.builders = nil; return (self.builders = ($truthy($a = self.builders) ? $a : $hash2([], {}))) }, $Builder_to_h$3.$$arity = 0); Opal.defs(self, '$for', $Builder_for$4 = function(klass) { var $iter = $Builder_for$4.$$p, block = $iter || nil, self = this, $writer = nil; if ($iter) $Builder_for$4.$$p = null; if ($iter) $Builder_for$4.$$p = null;; if ($truthy(block)) { $writer = [klass, block]; $send(self.$to_h(), '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; } else { return self.$to_h()['$[]'](klass) }; }, $Builder_for$4.$$arity = 1); Opal.defs(self, '$build', $Builder_build$5 = function $$build(builder, item) {try { var $$6, self = this; $send(self.$to_h(), 'each', [], ($$6 = function(klass, block){var self = $$6.$$s || this; if (klass == null) { klass = nil; }; if (block == null) { block = nil; }; if ($truthy(klass['$==='](item))) { Opal.ret(block.$call(builder, item)) } else { return nil };}, $$6.$$s = self, $$6.$$arity = 2, $$6)); return self.$raise($$($nesting, 'ArgumentError'), "" + "cannot build unknown item " + (item)); } catch ($returner) { if ($returner === Opal.returner) { return $returner.$v } throw $returner; } }, $Builder_build$5.$$arity = 2); self.$attr_reader("document", "element"); Opal.def(self, '$initialize', $Builder_initialize$7 = function $$initialize(document) { var $iter = $Builder_initialize$7.$$p, block = $iter || nil, $$8, self = this; if ($iter) $Builder_initialize$7.$$p = null; if ($iter) $Builder_initialize$7.$$p = null;; self.document = document; self.builder = $send($$$($$($nesting, 'Paggio'), 'HTML'), 'new', [], block.$to_proc()); return (self.roots = $send(self.builder.$each(), 'map', [], ($$8 = function(e){var self = $$8.$$s || this; if (e == null) { e = nil; }; return $$($nesting, 'Builder').$build(self, e);}, $$8.$$s = self, $$8.$$arity = 1, $$8))); }, $Builder_initialize$7.$$arity = 1); return (Opal.def(self, '$to_a', $Builder_to_a$9 = function $$to_a() { var self = this; return self.roots }, $Builder_to_a$9.$$arity = 0), nil) && 'to_a'; })($nesting[0], null, $nesting); $send($$($nesting, 'Builder'), 'for', [$$($nesting, 'String')], ($DOM$10 = function(b, item){var self = $DOM$10.$$s || this; if (b == null) { b = nil; }; if (item == null) { item = nil; }; return b.$document().$create_text(item);}, $DOM$10.$$s = self, $DOM$10.$$arity = 2, $DOM$10)); $send($$($nesting, 'Builder'), 'for', [$$$($$$($$($nesting, 'Paggio'), 'HTML'), 'Element')], ($DOM$11 = function(b, item){var self = $DOM$11.$$s || this, $$12, $$13, $$14, dom = nil, on = nil, inner = nil, $writer = nil; if (b == null) { b = nil; }; if (item == null) { item = nil; }; dom = b.$document().$create_element(item.name); if ($truthy($$($nesting, 'Hash')['$==='](item.attributes))) { dom.$attributes()['$merge!'](item.attributes)}; $send((item.class_names), 'each', [], ($$12 = function(value){var self = $$12.$$s || this; if (value == null) { value = nil; }; return dom.$add_class(value);}, $$12.$$s = self, $$12.$$arity = 1, $$12)); if ($truthy((on = item.on || nil))) { $send(on, 'each', [], ($$13 = function(args, block){var self = $$13.$$s || this; if (args == null) { args = nil; }; if (block == null) { block = nil; }; return $send(dom, 'on', Opal.to_a(args), block.$to_proc());}, $$13.$$s = self, $$13.$$arity = 2, $$13))}; if ($truthy((inner = item.inner_html || nil))) { $writer = [inner]; $send(dom, 'inner_html=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; } else { $send(item, 'each', [], ($$14 = function(child){var self = $$14.$$s || this; if (child == null) { child = nil; }; return dom['$<<']($$($nesting, 'Builder').$build(b, child));}, $$14.$$s = self, $$14.$$arity = 1, $$14)) }; return dom;}, $DOM$11.$$s = self, $DOM$11.$$arity = 2, $DOM$11)); $send($$($nesting, 'Builder'), 'for', [$$$($$($nesting, 'DOM'), 'Node')], ($DOM$15 = function(b, item){var self = $DOM$15.$$s || this; if (b == null) { b = nil; }; if (item == null) { item = nil; }; return item;}, $DOM$15.$$s = self, $DOM$15.$$arity = 2, $DOM$15)); })($nesting[0], $nesting) })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom/mutation_observer"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $hash2 = Opal.hash2; Opal.add_stubs(['$supports?', '$include', '$===', '$==', '$type', '$new', '$[]', '$DOM', '$alias_native', '$call', '$map', '$convert', '$private', '$Native', '$[]=', '$-', '$to_n']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'DOM'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'MutationObserver'); var $nesting = [self].concat($parent_nesting), $MutationObserver_supported$ques$1, $MutationObserver_initialize$9, $MutationObserver_observe$11, $MutationObserver_take$12, $MutationObserver_disconnect$14, $MutationObserver_convert$15; self.$$prototype["native"] = nil; Opal.defs(self, '$supported?', $MutationObserver_supported$ques$1 = function() { var self = this; return $$($nesting, 'Browser')['$supports?']("MutationObserver") }, $MutationObserver_supported$ques$1.$$arity = 0); self.$include($$($nesting, 'Native')); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Record'); var $nesting = [self].concat($parent_nesting), $Record_type$2, $Record_attribute$ques$3, $Record_tree$ques$4, $Record_cdata$ques$5, $Record_added$6, $Record_removed$7, $Record_target$8; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$type', $Record_type$2 = function $$type() { var self = this, $case = nil; return (function() {$case = self["native"].type; if ("attributes"['$===']($case)) {return "attribute"} else if ("childList"['$===']($case)) {return "tree"} else if ("characterData"['$===']($case)) {return "cdata"} else { return nil }})() }, $Record_type$2.$$arity = 0); Opal.def(self, '$attribute?', $Record_attribute$ques$3 = function() { var self = this; return self.$type()['$==']("attribute") }, $Record_attribute$ques$3.$$arity = 0); Opal.def(self, '$tree?', $Record_tree$ques$4 = function() { var self = this; return self.$type()['$==']("tree") }, $Record_tree$ques$4.$$arity = 0); Opal.def(self, '$cdata?', $Record_cdata$ques$5 = function() { var self = this; return self.$type()['$==']("cdata") }, $Record_cdata$ques$5.$$arity = 0); Opal.def(self, '$added', $Record_added$6 = function $$added() { var self = this, array = nil; array = (function() {if ($truthy(self["native"].addedNodes != null)) { return $$$($$($nesting, 'Native'), 'Array').$new(self["native"].addedNodes) } else { return [] }; return nil; })(); return $$($nesting, 'NodeSet')['$[]'](array); }, $Record_added$6.$$arity = 0); Opal.def(self, '$removed', $Record_removed$7 = function $$removed() { var self = this, array = nil; array = (function() {if ($truthy(self["native"].removedNodes != null)) { return $$$($$($nesting, 'Native'), 'Array').$new(self["native"].removedNodes) } else { return [] }; return nil; })(); return $$($nesting, 'NodeSet')['$[]'](array); }, $Record_removed$7.$$arity = 0); Opal.def(self, '$target', $Record_target$8 = function $$target() { var self = this; return self.$DOM(self["native"].target) }, $Record_target$8.$$arity = 0); self.$alias_native("old", "oldValue"); self.$alias_native("name", "attributeName"); return self.$alias_native("namespace", "attributeNamespace"); })($nesting[0], null, $nesting); Opal.def(self, '$initialize', $MutationObserver_initialize$9 = function $$initialize() { var $iter = $MutationObserver_initialize$9.$$p, block = $iter || nil, $$10, self = this; if ($iter) $MutationObserver_initialize$9.$$p = null; if ($iter) $MutationObserver_initialize$9.$$p = null;; var func = function(records) { return block.$call($send((records), 'map', [], ($$10 = function(r){var self = $$10.$$s || this; if (r == null) { r = nil; }; return $$$($$$($$$($$($nesting, 'Browser'), 'DOM'), 'MutationObserver'), 'Record').$new(r);}, $$10.$$s = self, $$10.$$arity = 1, $$10))); } ; return $send(self, Opal.find_super_dispatcher(self, 'initialize', $MutationObserver_initialize$9, false), [new window.MutationObserver(func)], null); }, $MutationObserver_initialize$9.$$arity = 0); Opal.def(self, '$observe', $MutationObserver_observe$11 = function $$observe(target, options) { var self = this; if (options == null) { options = nil; }; if ($truthy(options)) { } else { options = $hash2(["children", "tree", "attributes", "cdata"], {"children": true, "tree": true, "attributes": "old", "cdata": "old"}) }; self["native"].observe($$($nesting, 'Native').$convert(target), self.$convert(options)); return self; }, $MutationObserver_observe$11.$$arity = -2); Opal.def(self, '$take', $MutationObserver_take$12 = function $$take() { var $$13, self = this; return $send((self["native"].takeRecords()), 'map', [], ($$13 = function(r){var self = $$13.$$s || this; if (r == null) { r = nil; }; return $$($nesting, 'Record').$new(r);}, $$13.$$s = self, $$13.$$arity = 1, $$13)) }, $MutationObserver_take$12.$$arity = 0); Opal.def(self, '$disconnect', $MutationObserver_disconnect$14 = function $$disconnect() { var self = this; return self["native"].disconnect() }, $MutationObserver_disconnect$14.$$arity = 0); self.$private(); return (Opal.def(self, '$convert', $MutationObserver_convert$15 = function $$convert(hash) { var self = this, options = nil, $writer = nil, attrs = nil, filter = nil, cdata = nil; options = self.$Native({}); if ($truthy(hash['$[]']("children"))) { $writer = ["childList", true]; $send(options, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];}; if ($truthy(hash['$[]']("tree"))) { $writer = ["subtree", true]; $send(options, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];}; if ($truthy((attrs = hash['$[]']("attributes")))) { $writer = ["attributes", true]; $send(options, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; if (attrs['$==']("old")) { $writer = ["attributeOldValue", true]; $send(options, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];};}; if ($truthy((filter = hash['$[]']("filter")))) { $writer = ["attributeFilter", filter]; $send(options, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];}; if ($truthy((cdata = hash['$[]']("cdata")))) { $writer = ["characterData", true]; $send(options, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; if (cdata['$==']("old")) { $writer = ["characterDataOldValue", true]; $send(options, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];};}; return options.$to_n(); }, $MutationObserver_convert$15.$$arity = 1), nil) && 'convert'; })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/dom"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $truthy = Opal.truthy, $gvars = Opal.gvars, $send = Opal.send, $klass = Opal.klass; if ($gvars.window == null) $gvars.window = nil; Opal.add_stubs(['$require', '$DOM', '$shift', '$to_a', '$new', '$to_proc', '$==', '$length', '$first', '$native?', '$===', '$try_convert', '$raise', '$document']); self.$require("browser/dom/node_set"); self.$require("browser/dom/node"); self.$require("browser/dom/attribute"); self.$require("browser/dom/character_data"); self.$require("browser/dom/text"); self.$require("browser/dom/cdata"); self.$require("browser/dom/comment"); self.$require("browser/dom/element"); self.$require("browser/dom/document"); self.$require("browser/dom/document_fragment"); self.$require("browser/dom/builder"); self.$require("browser/dom/mutation_observer"); (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_XML$1, $Kernel_DOM$2; Opal.def(self, '$XML', $Kernel_XML$1 = function $$XML(what) { var self = this; var doc; if (window.DOMParser) { doc = new DOMParser().parseFromString(what, 'text/xml'); } else { doc = new ActiveXObject('Microsoft.XMLDOM'); doc.async = 'false'; doc.loadXML(what); } ; return self.$DOM(doc); }, $Kernel_XML$1.$$arity = 1); Opal.def(self, '$DOM', $Kernel_DOM$2 = function $$DOM($a) { var $iter = $Kernel_DOM$2.$$p, block = $iter || nil, $post_args, args, $b, self = this, document = nil, roots = nil, what = nil; if ($gvars.document == null) $gvars.document = nil; if ($iter) $Kernel_DOM$2.$$p = null; if ($iter) $Kernel_DOM$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; if ($truthy(block)) { document = ($truthy($b = args.$shift()) ? $b : $gvars.document); roots = $send($$$($$$($$($nesting, 'Browser'), 'DOM'), 'Builder'), 'new', [document], block.$to_proc()).$to_a(); if (roots.$length()['$=='](1)) { return roots.$first() } else { return $$$($$$($$($nesting, 'Browser'), 'DOM'), 'NodeSet').$new(roots) }; } else { what = args.$shift(); document = ($truthy($b = args.$shift()) ? $b : $gvars.document); if ($truthy(self['$native?'](what))) { return $$$($$$($$($nesting, 'Browser'), 'DOM'), 'Node').$new(what) } else if ($truthy($$$($$$($$($nesting, 'Browser'), 'DOM'), 'Node')['$==='](what))) { return what } else if ($truthy($$($nesting, 'String')['$==='](what))) { var doc = $$($nesting, 'Native').$try_convert(document).createElement('div'); doc.innerHTML = what; return self.$DOM(doc.childNodes.length == 1 ? doc.childNodes[0] : doc); } else { return self.$raise($$($nesting, 'ArgumentError'), "argument not DOM convertible") }; }; }, $Kernel_DOM$2.$$arity = -1); })($nesting[0], $nesting); (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Window'); var $nesting = [self].concat($parent_nesting), $Window_document$3; self.$$prototype["native"] = nil; return (Opal.def(self, '$document', $Window_document$3 = function $$document() { var self = this; return self.$DOM(self["native"].document) }, $Window_document$3.$$arity = 0), nil) && 'document' })($nesting[0], null, $nesting) })($nesting[0], $nesting); return ($gvars.document = $gvars.window.$document()); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/css/declaration"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send, $range = Opal.range; Opal.add_stubs(['$include', '$new', '$each', '$[]=', '$-', '$to_proc', '$important', '$name', '$value', '$to_s', '$enum_for', '$[]', '$alias_native', '$end_with?']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'CSS'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Declaration'); var $nesting = [self].concat($parent_nesting), $Declaration_rule$1, $Declaration_assign$2, $Declaration_replace$4, $Declaration_apply$5, $Declaration_delete$7, $Declaration_$$$8, $Declaration_$$$eq$9, $Declaration_important$ques$10, $Declaration_each$11, $Declaration_method_missing$12; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); self.$include($$($nesting, 'Enumerable')); Opal.def(self, '$rule', $Declaration_rule$1 = function $$rule() { var self = this; if ($truthy((typeof(self["native"].parentRule) !== "undefined"))) { return $$($nesting, 'Rule').$new(self["native"].parentRule) } else { return nil } }, $Declaration_rule$1.$$arity = 0); Opal.def(self, '$assign', $Declaration_assign$2 = function $$assign(data) { var $$3, self = this; $send(data, 'each', [], ($$3 = function(name, value){var self = $$3.$$s || this, $writer = nil; if (name == null) { name = nil; }; if (value == null) { value = nil; }; $writer = [name, value]; $send(self, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)];}, $$3.$$s = self, $$3.$$arity = 2, $$3)); return self; }, $Declaration_assign$2.$$arity = 1); Opal.def(self, '$replace', $Declaration_replace$4 = function $$replace(string) { var self = this; return self["native"].cssText = string }, $Declaration_replace$4.$$arity = 1); Opal.def(self, '$apply', $Declaration_apply$5 = function $$apply() { var $iter = $Declaration_apply$5.$$p, block = $iter || nil, $$6, self = this; if ($iter) $Declaration_apply$5.$$p = null; if ($iter) $Declaration_apply$5.$$p = null;; return $send($send($$$($$$($$($nesting, 'Paggio'), 'CSS'), 'Definition'), 'new', [], block.$to_proc()), 'each', [], ($$6 = function(style){var self = $$6.$$s || this; if (self["native"] == null) self["native"] = nil; if (style == null) { style = nil; }; if ($truthy(style.$important())) { return self["native"].setProperty(style.$name(), style.$value(), "important") } else { return self["native"].setProperty(style.$name(), style.$value(), "") };}, $$6.$$s = self, $$6.$$arity = 1, $$6)); }, $Declaration_apply$5.$$arity = 0); Opal.def(self, '$delete', $Declaration_delete$7 = function(name) { var self = this; return self["native"].removeProperty(name) }, $Declaration_delete$7.$$arity = 1); Opal.def(self, '$[]', $Declaration_$$$8 = function(name) { var self = this; var result = self["native"].getPropertyValue(name); if (result == null || result === "") { return nil; } return result; }, $Declaration_$$$8.$$arity = 1); Opal.def(self, '$[]=', $Declaration_$$$eq$9 = function(name, value) { var self = this; return self["native"].setProperty(name, value.$to_s(), "") }, $Declaration_$$$eq$9.$$arity = 2); Opal.def(self, '$important?', $Declaration_important$ques$10 = function(name) { var self = this; return self["native"].getPropertyPriority(name) == "important" }, $Declaration_important$ques$10.$$arity = 1); Opal.def(self, '$each', $Declaration_each$11 = function $$each() { var $iter = $Declaration_each$11.$$p, block = $iter || nil, self = this; if ($iter) $Declaration_each$11.$$p = null; if ($iter) $Declaration_each$11.$$p = null;; if ((block !== nil)) { } else { return self.$enum_for("each") }; for (var i = 0, length = self["native"].length; i < length; i++) { var name = self["native"].item(i); Opal.yieldX(block, [name, self['$[]'](name)]) } ; return self; }, $Declaration_each$11.$$arity = 0); self.$alias_native("length"); self.$alias_native("to_s", "cssText"); return (Opal.def(self, '$method_missing', $Declaration_method_missing$12 = function $$method_missing(name, value) { var self = this, $writer = nil; if (value == null) { value = nil; }; if ($truthy(name['$end_with?']("="))) { $writer = [name['$[]']($range(0, -2, false)), value]; $send(self, '[]=', Opal.to_a($writer)); return $writer[$rb_minus($writer["length"], 1)]; } else { return self['$[]'](name) }; }, $Declaration_method_missing$12.$$arity = -2), nil) && 'method_missing'; })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/css/style_sheet"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$include', '$is_a?', '$to_n', '$alias_native', '$new', '$DOM', '$===', '$join', '$map', '$insert', '$length', '$find', '$rules', '$log', '$==', '$id', '$__send__', '$to_proc']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'CSS'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'StyleSheet'); var $nesting = [self].concat($parent_nesting), $StyleSheet_initialize$1, $StyleSheet_media$2, $StyleSheet_owner$3, $StyleSheet_parent$4, $StyleSheet_rules$5, $StyleSheet_delete$7, $StyleSheet_insert$8, $StyleSheet_rule$9, $StyleSheet_$$$11, $StyleSheet_method_missing$13; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$initialize', $StyleSheet_initialize$1 = function $$initialize(what) { var $iter = $StyleSheet_initialize$1.$$p, $yield = $iter || nil, self = this; if ($iter) $StyleSheet_initialize$1.$$p = null; if ($truthy(what['$is_a?']($$$($$($nesting, 'DOM'), 'Element')))) { return $send(self, Opal.find_super_dispatcher(self, 'initialize', $StyleSheet_initialize$1, false), [what.$to_n().sheet], null) } else { return $send(self, Opal.find_super_dispatcher(self, 'initialize', $StyleSheet_initialize$1, false), [what], null) } }, $StyleSheet_initialize$1.$$arity = 1); self.$alias_native("disabled?", "disabled"); self.$alias_native("href"); self.$alias_native("title"); self.$alias_native("type"); Opal.def(self, '$media', $StyleSheet_media$2 = function $$media() { var self = this; if ($truthy(self["native"].media != null)) { return $$($nesting, 'Media').$new(self["native"].media) } else { return nil } }, $StyleSheet_media$2.$$arity = 0); Opal.def(self, '$owner', $StyleSheet_owner$3 = function $$owner() { var self = this; return self.$DOM(self["native"].ownerNode) }, $StyleSheet_owner$3.$$arity = 0); Opal.def(self, '$parent', $StyleSheet_parent$4 = function $$parent() { var self = this; if ($truthy(self["native"].parentStyleSheet != null)) { return $$($nesting, 'Sheet').$new(self["native"].parentStyleSheet) } else { return nil } }, $StyleSheet_parent$4.$$arity = 0); Opal.def(self, '$rules', $StyleSheet_rules$5 = function $$rules() { var $$6, self = this; return $send($$$($$($nesting, 'Native'), 'Array'), 'new', [self["native"].cssRules], ($$6 = function(e){var self = $$6.$$s || this; if (e == null) { e = nil; }; return $$($nesting, 'Rule').$new(e);}, $$6.$$s = self, $$6.$$arity = 1, $$6)) }, $StyleSheet_rules$5.$$arity = 0); Opal.def(self, '$delete', $StyleSheet_delete$7 = function(index) { var self = this; return self["native"].deleteRule(index) }, $StyleSheet_delete$7.$$arity = 1); Opal.def(self, '$insert', $StyleSheet_insert$8 = function $$insert(index, rule) { var self = this; return self["native"].insertRule(rule, index) }, $StyleSheet_insert$8.$$arity = 2); Opal.def(self, '$rule', $StyleSheet_rule$9 = function $$rule(selector, body) { var $$10, self = this; if ($truthy($$($nesting, 'String')['$==='](selector))) { } else { selector = selector.$join(", ") }; if ($truthy($$($nesting, 'String')['$==='](body))) { } else { body = $send(body, 'map', [], ($$10 = function(name, value){var self = $$10.$$s || this; if (name == null) { name = nil; }; if (value == null) { value = nil; }; return "" + (name) + ": " + (value) + ";";}, $$10.$$s = self, $$10.$$arity = 2, $$10)).$join("\n") }; return self.$insert(self.$length(), "" + (selector) + " { " + (body) + " }"); }, $StyleSheet_rule$9.$$arity = 2); Opal.def(self, '$[]', $StyleSheet_$$$11 = function(id) { var $$12, self = this; return $send(self.$rules(), 'find', [], ($$12 = function(r){var self = $$12.$$s || this; if (r == null) { r = nil; }; self.$log(r); return r.$id()['$=='](id);}, $$12.$$s = self, $$12.$$arity = 1, $$12)) }, $StyleSheet_$$$11.$$arity = 1); Opal.def(self, '$method_missing', $StyleSheet_method_missing$13 = function $$method_missing($a) { var $iter = $StyleSheet_method_missing$13.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $StyleSheet_method_missing$13.$$p = null; if ($iter) $StyleSheet_method_missing$13.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.$rules(), '__send__', Opal.to_a(args), block.$to_proc()); }, $StyleSheet_method_missing$13.$$arity = -1); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Media'); var $nesting = [self].concat($parent_nesting), $Media_push$14, $Media_delete$15; self.$$prototype["native"] = nil; self.$alias_native("text", "mediaText"); self.$alias_native("to_s", "mediaText"); Opal.def(self, '$push', $Media_push$14 = function $$push(medium) { var self = this; self["native"].appendMedium(medium); return self; }, $Media_push$14.$$arity = 1); return (Opal.def(self, '$delete', $Media_delete$15 = function(medium) { var self = this; return self["native"].deleteMedium(medium) }, $Media_delete$15.$$arity = 1), nil) && 'delete'; })($nesting[0], $$$($$($nesting, 'Native'), 'Array'), $nesting); })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/css/rule"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy, $send = Opal.send; Opal.add_stubs(['$include', '$==', '$[]', '$new', '$raise', '$alias_native']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'CSS'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Rule'); var $nesting = [self].concat($parent_nesting), $Rule_new$1, $Rule_parent$2, $Rule_style_sheet$3; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.const_set($nesting[0], 'STYLE_RULE', 1); Opal.const_set($nesting[0], 'CHARSET_RULE', 2); Opal.const_set($nesting[0], 'IMPORT_RULE', 3); Opal.const_set($nesting[0], 'MEDIA_RULE', 4); Opal.const_set($nesting[0], 'FONT_FACE_RULE', 5); Opal.const_set($nesting[0], 'PAGE_RULE', 6); Opal.const_set($nesting[0], 'KEYFRAMES_RULE', 7); Opal.const_set($nesting[0], 'KEYFRAME_RULE', 8); Opal.const_set($nesting[0], 'NAMESPACE_RULE', 10); Opal.const_set($nesting[0], 'COUNTER_STYLE_RULE', 11); Opal.const_set($nesting[0], 'SUPPORTS_RULE', 12); Opal.const_set($nesting[0], 'DOCUMENT_RULE', 13); Opal.const_set($nesting[0], 'FONT_FEATURE_VALUES_RULE', 14); Opal.const_set($nesting[0], 'VIEWPORT_RULE', 15); Opal.const_set($nesting[0], 'REGION_STYLE_RULE', 16); Opal.defs(self, '$new', $Rule_new$1 = function(rule) { var $a, $iter = $Rule_new$1.$$p, $yield = $iter || nil, self = this, klass = nil; if (self.classes == null) self.classes = nil; if ($iter) $Rule_new$1.$$p = null; if (self['$==']($$($nesting, 'Rule'))) { self.classes = ($truthy($a = self.classes) ? $a : [nil, $$($nesting, 'Style')]); if ($truthy((klass = self.classes['$[]'](rule.type)))) { return klass.$new(rule) } else { return self.$raise($$($nesting, 'ArgumentError'), "cannot instantiate a non derived Rule object") }; } else { return $send(self, Opal.find_super_dispatcher(self, 'new', $Rule_new$1, false, self.$$class.$$prototype), [rule], null) } }, $Rule_new$1.$$arity = 1); self.$alias_native("text", "cssText"); self.$alias_native("to_s", "cssText"); Opal.def(self, '$parent', $Rule_parent$2 = function $$parent() { var self = this; if ($truthy(self["native"].parentRule != null)) { return $$($nesting, 'Rule').$new(self["native"].parentRule) } else { return nil } }, $Rule_parent$2.$$arity = 0); return (Opal.def(self, '$style_sheet', $Rule_style_sheet$3 = function $$style_sheet() { var self = this; if ($truthy(self["native"].parentStyleSheet != null)) { return $$($nesting, 'StyleSheet').$new(self["native"].parentStyleSheet) } else { return nil } }, $Rule_style_sheet$3.$$arity = 0), nil) && 'style_sheet'; })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/css/rule/style"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$alias_native', '$new', '$__send__', '$declaration', '$to_proc']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $parent_nesting) { var self = $module($base, 'CSS'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Rule'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Style'); var $nesting = [self].concat($parent_nesting), $Style_declaration$1, $Style_method_missing$2; self.$$prototype["native"] = nil; self.$alias_native("selector", "selectorText"); self.$alias_native("id", "selectorText"); Opal.def(self, '$declaration', $Style_declaration$1 = function $$declaration() { var self = this; return $$($nesting, 'Declaration').$new(self["native"].style) }, $Style_declaration$1.$$arity = 0); return (Opal.def(self, '$method_missing', $Style_method_missing$2 = function $$method_missing($a) { var $iter = $Style_method_missing$2.$$p, block = $iter || nil, $post_args, args, self = this; if ($iter) $Style_method_missing$2.$$p = null; if ($iter) $Style_method_missing$2.$$p = null;; $post_args = Opal.slice.call(arguments, 0, arguments.length); args = $post_args;; return $send(self.$declaration(), '__send__', Opal.to_a(args), block.$to_proc()); }, $Style_method_missing$2.$$arity = -1), nil) && 'method_missing'; })($nesting[0], $$($nesting, 'Rule'), $nesting) })($nesting[0], null, $nesting) })($nesting[0], $nesting) })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/css"] = function(Opal) { function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $gvars = Opal.gvars, $send = Opal.send, $truthy = Opal.truthy; Opal.add_stubs(['$require', '$create_element', '$[]=', '$-', '$css', '$to_proc', '$inner_text=']); self.$require("browser/css/declaration"); self.$require("browser/css/style_sheet"); self.$require("browser/css/rule"); self.$require("browser/css/rule/style"); return (function($base, $parent_nesting) { var self = $module($base, 'Kernel'); var $nesting = [self].concat($parent_nesting), $Kernel_CSS$1; Opal.def(self, '$CSS', $Kernel_CSS$1 = function $$CSS(text) { var $iter = $Kernel_CSS$1.$$p, block = $iter || nil, self = this, style = nil, $writer = nil; if ($gvars.document == null) $gvars.document = nil; if ($iter) $Kernel_CSS$1.$$p = null; if ($iter) $Kernel_CSS$1.$$p = null;; if (text == null) { text = nil; }; style = $gvars.document.$create_element("style"); $writer = ["type", "text/css"]; $send(style, '[]=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)];; if ($truthy(block)) { $writer = [$send($$($nesting, 'Paggio'), 'css', [], block.$to_proc())]; $send(style, 'inner_text=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; } else { $writer = [text]; $send(style, 'inner_text=', Opal.to_a($writer)); $writer[$rb_minus($writer["length"], 1)]; }; return style; }, $Kernel_CSS$1.$$arity = -1) })($nesting[0], $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice; Opal.add_stubs(['$require']); self.$require("native"); self.$require("paggio"); self.$require("browser/version"); self.$require("browser/utils"); self.$require("browser/support"); self.$require("browser/event"); self.$require("browser/window"); self.$require("browser/dom"); return self.$require("browser/css"); }; /* Generated by Opal 1.0.3 */ Opal.modules["browser/location"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $module = Opal.module, $klass = Opal.klass, $truthy = Opal.truthy; Opal.add_stubs(['$include', '$to_s', '$alias_native', '$new']); return (function($base, $parent_nesting) { var self = $module($base, 'Browser'); var $nesting = [self].concat($parent_nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Location'); var $nesting = [self].concat($parent_nesting), $Location_assign$1, $Location_replace$2, $Location_reload$3, $Location_to_s$4; self.$$prototype["native"] = nil; self.$include($$($nesting, 'Native')); Opal.def(self, '$assign', $Location_assign$1 = function $$assign(url) { var self = this; return self["native"].assign(url.$to_s()) }, $Location_assign$1.$$arity = 1); Opal.def(self, '$replace', $Location_replace$2 = function $$replace(url) { var self = this; return self["native"].replace(url.$to_s()) }, $Location_replace$2.$$arity = 1); Opal.def(self, '$reload', $Location_reload$3 = function $$reload(force) { var self = this; if (force == null) { force = false; }; return self["native"].reload(force); }, $Location_reload$3.$$arity = -1); Opal.def(self, '$to_s', $Location_to_s$4 = function $$to_s() { var self = this; return self["native"].toString() }, $Location_to_s$4.$$arity = 0); self.$alias_native("fragment", "hash"); self.$alias_native("fragment=", "hash="); self.$alias_native("host"); self.$alias_native("host="); self.$alias_native("uri", "href"); self.$alias_native("uri=", "href="); self.$alias_native("path", "pathname"); self.$alias_native("path=", "pathname="); self.$alias_native("port"); self.$alias_native("port="); self.$alias_native("scheme", "protocol"); self.$alias_native("scheme=", "protocol="); self.$alias_native("query", "search"); return self.$alias_native("query=", "search="); })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Window'); var $nesting = [self].concat($parent_nesting), $Window_location$5; self.$$prototype["native"] = nil; return (Opal.def(self, '$location', $Window_location$5 = function $$location() { var self = this; if ($truthy(self["native"].location)) { return $$($nesting, 'Location').$new(self["native"].location) } else { return nil } }, $Window_location$5.$$arity = 0), nil) && 'location' })($nesting[0], null, $nesting); (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Document'); var $nesting = [self].concat($parent_nesting), $Document_location$6; self.$$prototype["native"] = nil; return (Opal.def(self, '$location', $Document_location$6 = function $$location() { var self = this; if ($truthy(self["native"].location)) { return $$($nesting, 'Location').$new(self["native"].location) } else { return nil } }, $Document_location$6.$$arity = 0), nil) && 'location' })($$($nesting, 'DOM'), $$$($$($nesting, 'DOM'), 'Element'), $nesting); })($nesting[0], $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["sidebar/expander"] = function(Opal) { var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send; Opal.add_stubs(['$setup', '$new', '$on_toggle_sidebar', '$on_expand_all', '$find', '$on', '$prevent_default', '$toggle_class', '$html', '$==', '$each', '$expand_carret', '$collapse_carret', '$removeClass', '$hide', '$siblings', '$addClass', '$show']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Sidebar'); var $nesting = [self].concat($parent_nesting); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Expander'); var $nesting = [self].concat($parent_nesting), $Expander_setup$1, $Expander_setup$2, $Expander_on_toggle_sidebar$3, $Expander_on_expand_all$5, $Expander_expand_carret$8, $Expander_collapse_carret$9; Opal.defs(self, '$setup', $Expander_setup$1 = function $$setup() { var self = this; return self.$new().$setup() }, $Expander_setup$1.$$arity = 0); Opal.def(self, '$setup', $Expander_setup$2 = function $$setup() { var self = this; self.$on_toggle_sidebar(); return self.$on_expand_all(); }, $Expander_setup$2.$$arity = 0); Opal.def(self, '$on_toggle_sidebar', $Expander_on_toggle_sidebar$3 = function $$on_toggle_sidebar() { var $$4, self = this, menu = nil; menu = $$($nesting, 'Element').$find("#menu-toggle"); return $send(menu, 'on', ["click"], ($$4 = function(e){var self = $$4.$$s || this, sidebar = nil; if (e == null) { e = nil; }; e.$prevent_default(); sidebar = $$($nesting, 'Element').$find("#sidebar"); sidebar.$toggle_class("toggled"); return menu.$toggle_class("cross");}, $$4.$$s = self, $$4.$$arity = 1, $$4)); }, $Expander_on_toggle_sidebar$3.$$arity = 0); Opal.def(self, '$on_expand_all', $Expander_on_expand_all$5 = function $$on_expand_all() { var $$6, self = this, expand_all = nil; expand_all = $$($nesting, 'Element').$find("#expand-all"); self.html = expand_all.$html(); return $send(expand_all, 'on', ["click"], ($$6 = function(e){var self = $$6.$$s || this, $$7, sidebar = nil, carets = nil; if (self.html == null) self.html = nil; if (e == null) { e = nil; }; self.html = (function() {if (self.html['$==']("expand all")) { return "collapse all" } else { return "expand all" }; return nil; })(); expand_all.$html(self.html); sidebar = $$($nesting, 'Element').$find("#sidebar"); carets = sidebar.$find("span.caret"); return $send(carets, 'each', [], ($$7 = function(caret){var self = $$7.$$s || this; if (self.html == null) self.html = nil; if (caret == null) { caret = nil; }; if (self.html['$==']("expand all")) { return self.$expand_carret(caret) } else { return self.$collapse_carret(caret) };}, $$7.$$s = self, $$7.$$arity = 1, $$7));}, $$6.$$s = self, $$6.$$arity = 1, $$6)); }, $Expander_on_expand_all$5.$$arity = 0); Opal.def(self, '$expand_carret', $Expander_expand_carret$8 = function $$expand_carret(caret) { var self = this; caret.$removeClass("caret-down"); return caret.$siblings("ul").$hide(); }, $Expander_expand_carret$8.$$arity = 1); return (Opal.def(self, '$collapse_carret', $Expander_collapse_carret$9 = function $$collapse_carret(caret) { var self = this; caret.$addClass("caret-down"); return caret.$siblings("ul").$show(); }, $Expander_collapse_carret$9.$$arity = 1), nil) && 'collapse_carret'; })($nesting[0], null, $nesting) })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ Opal.modules["sidebar"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $gvars = Opal.gvars; Opal.add_stubs(['$require', '$find', '$children', '$each', '$setup', '$new', '$add_carets', '$on_toggle_caret', '$init_carets', '$expand_to_current', '$==', '$tag_name', '$>', '$size', '$prepend', '$on', '$target', '$has_class?', '$toggleClass', '$siblings', '$toggle', '$click', '$path', '$location', '$first', '$select', '$attr', '$add_class', '$prev', '$parents', '$prevAll']); self.$require("sidebar/expander"); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Sidebar'); var $nesting = [self].concat($parent_nesting), $Sidebar_initialize$3, $Sidebar_setup$4, $Sidebar_add_carets$5, $Sidebar_on_toggle_caret$7, $Sidebar_init_carets$9, $Sidebar_expand_to_current$11; self.$$prototype.sidenav = nil; (function(self, $parent_nesting) { var $nesting = [self].concat($parent_nesting), $setup$1; return (Opal.def(self, '$setup', $setup$1 = function $$setup() { var $$2, self = this, section = nil, urls = nil; section = $$($nesting, 'Element').$find(".content-nav"); urls = section.$children("ul"); $send(urls, 'each', [], ($$2 = function(ul){var self = $$2.$$s || this; if (ul == null) { ul = nil; }; return self.$new(ul).$setup();}, $$2.$$s = self, $$2.$$arity = 1, $$2)); return $$($nesting, 'Expander').$setup(); }, $setup$1.$$arity = 0), nil) && 'setup' })(Opal.get_singleton_class(self), $nesting); Opal.def(self, '$initialize', $Sidebar_initialize$3 = function $$initialize(el) { var self = this; return (self.sidenav = el) }, $Sidebar_initialize$3.$$arity = 1); Opal.def(self, '$setup', $Sidebar_setup$4 = function $$setup() { var self = this; self.$add_carets(self.sidenav); self.$on_toggle_caret(); self.$init_carets(); return self.$expand_to_current(); }, $Sidebar_setup$4.$$arity = 0); Opal.def(self, '$add_carets', $Sidebar_add_carets$5 = function $$add_carets(node) { var $$6, self = this; if (node.$tag_name()['$==']("li")) { if ($truthy($rb_gt(node.$children("ul").$size(), 0))) { node.$prepend("") } else { node.$prepend("") }}; return $send(node.$children(), 'each', [], ($$6 = function(child){var self = $$6.$$s || this; if (child == null) { child = nil; }; return self.$add_carets(child);}, $$6.$$s = self, $$6.$$arity = 1, $$6)); }, $Sidebar_add_carets$5.$$arity = 1); Opal.def(self, '$on_toggle_caret', $Sidebar_on_toggle_caret$7 = function $$on_toggle_caret() { var $$8, self = this; return $send(self.sidenav, 'on', ["click"], ($$8 = function(event){var self = $$8.$$s || this, $a, target = nil, caret = nil, ul = nil; if (event == null) { event = nil; }; target = event.$target(); caret = ($truthy($a = target['$has_class?']("caret-down")) ? $a : target['$has_class?']("caret")); if ($truthy((($a = target.$tag_name()['$==']("span")) ? caret : target.$tag_name()['$==']("span")))) { target.$toggleClass("caret-down"); ul = target.$siblings("ul"); return ul.$toggle(); } else { return nil };}, $$8.$$s = self, $$8.$$arity = 1, $$8)) }, $Sidebar_on_toggle_caret$7.$$arity = 0); Opal.def(self, '$init_carets', $Sidebar_init_carets$9 = function $$init_carets() { var $$10, self = this; return $send(self.sidenav.$children(), 'each', [], ($$10 = function(child){var self = $$10.$$s || this, carets = nil; if (child == null) { child = nil; }; if (child.$tag_name()['$==']("li")) { } else { return nil; }; carets = child.$find("span.caret"); return carets.$click();}, $$10.$$s = self, $$10.$$arity = 1, $$10)) }, $Sidebar_init_carets$9.$$arity = 0); return (Opal.def(self, '$expand_to_current', $Sidebar_expand_to_current$11 = function $$expand_to_current() { var $$12, $$13, self = this, current_location = nil, links = nil, current_link = nil, sibling = nil, uls = nil; if ($gvars.window == null) $gvars.window = nil; current_location = $gvars.window.$location().$path(); links = self.sidenav.$find("a"); current_link = $send(links, 'select', [], ($$12 = function(l){var self = $$12.$$s || this; if (l == null) { l = nil; }; return l.$attr("href")['$=='](current_location);}, $$12.$$s = self, $$12.$$arity = 1, $$12)).$first(); if ($truthy(current_link)) { } else { return nil }; current_link.$add_class("current-page"); sibling = current_link.$prev("span"); if ($truthy(sibling)) { sibling.$click()}; uls = current_link.$parents("ul"); return $send(uls, 'each', [], ($$13 = function(ul){var self = $$13.$$s || this, span = nil; if (ul == null) { ul = nil; }; span = ul.$prevAll("span").$first(); if ($truthy(span)) { return span.$click() } else { return nil };}, $$13.$$s = self, $$13.$$arity = 1, $$13)); }, $Sidebar_expand_to_current$11.$$arity = 0), nil) && 'expand_to_current'; })($nesting[0], null, $nesting); }; /* Generated by Opal 1.0.3 */ Opal.modules["pager"] = function(Opal) { function $rb_gt(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs > rhs : lhs['$>'](rhs); } function $rb_minus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs - rhs : lhs['$-'](rhs); } function $rb_plus(lhs, rhs) { return (typeof(lhs) === 'number' && typeof(rhs) === 'number') ? lhs + rhs : lhs['$+'](rhs); } var self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $klass = Opal.klass, $send = Opal.send, $truthy = Opal.truthy, $gvars = Opal.gvars; Opal.add_stubs(['$setup', '$new', '$find', '$on_left_right', '$add_page_buttons', '$on_prev_next', '$on', '$which', '$===', '$goto_link', '$>', '$size', '$append', '$sidebar_links', '$find_current', '$index', '$==', '$-', '$+', '$at', '$attr', '$assign', '$location', '$path', '$first', '$select']); return (function($base, $super, $parent_nesting) { var self = $klass($base, $super, 'Pager'); var $nesting = [self].concat($parent_nesting), $Pager_setup$1, $Pager_initialize$2, $Pager_setup$3, $Pager_on_left_right$4, $Pager_add_page_buttons$6, $Pager_on_prev_next$7, $Pager_goto_link$10, $Pager_sidebar_links$11, $Pager_find_current$12; self.$$prototype.sidebar = nil; Opal.defs(self, '$setup', $Pager_setup$1 = function $$setup() { var self = this; return self.$new().$setup() }, $Pager_setup$1.$$arity = 0); Opal.def(self, '$initialize', $Pager_initialize$2 = function $$initialize() { var self = this; return (self.sidebar = $$($nesting, 'Element').$find("#sidebar")) }, $Pager_initialize$2.$$arity = 0); Opal.def(self, '$setup', $Pager_setup$3 = function $$setup() { var self = this; self.$on_left_right(); self.$add_page_buttons(); return self.$on_prev_next(); }, $Pager_setup$3.$$arity = 0); Opal.def(self, '$on_left_right', $Pager_on_left_right$4 = function $$on_left_right() { var $$5, self = this; return $send($$($nesting, 'Document'), 'on', ["keyup"], ($$5 = function(e){var self = $$5.$$s || this, $case = nil; if (e == null) { e = nil; }; return (function() {$case = e.$which(); if ((37)['$===']($case)) {return self.$goto_link("prev")} else if ((39)['$===']($case)) {return self.$goto_link("next")} else { return nil }})();}, $$5.$$s = self, $$5.$$arity = 1, $$5)) }, $Pager_on_left_right$4.$$arity = 0); Opal.def(self, '$add_page_buttons', $Pager_add_page_buttons$6 = function $$add_page_buttons() { var self = this, html = nil, fluid = nil; if ($truthy($rb_gt($$($nesting, 'Element').$find("#sidebar").$size(), 0))) { } else { return nil }; html = "" + "
\n" + " Back\n" + " Next Step\n" + "

Pro tip: Use the <- and -> arrow keys to move back and forward.

\n" + "
\n"; fluid = $$($nesting, 'Element').$find(".container-fluid"); return fluid.$append(html); }, $Pager_add_page_buttons$6.$$arity = 0); Opal.def(self, '$on_prev_next', $Pager_on_prev_next$7 = function $$on_prev_next() { var $$8, $$9, self = this, next_link = nil, prev_link = nil; next_link = $$($nesting, 'Element').$find("#next"); $send(next_link, 'on', ["click"], ($$8 = function(e){var self = $$8.$$s || this; if (e == null) { e = nil; }; return self.$goto_link("next");}, $$8.$$s = self, $$8.$$arity = 1, $$8)); prev_link = $$($nesting, 'Element').$find("#prev"); return $send(prev_link, 'on', ["click"], ($$9 = function(e){var self = $$9.$$s || this; if (e == null) { e = nil; }; return self.$goto_link("prev");}, $$9.$$s = self, $$9.$$arity = 1, $$9)); }, $Pager_on_prev_next$7.$$arity = 0); Opal.def(self, '$goto_link', $Pager_goto_link$10 = function $$goto_link(direction) { var self = this, links = nil, current_link = nil, current_index = nil, link = nil, last = nil, i = nil, href = nil; if ($gvars.window == null) $gvars.window = nil; links = self.$sidebar_links(); current_link = self.$find_current(); current_index = links.$index(current_link); link = (function() {if (direction['$==']("next")) { last = current_index['$==']($rb_minus(links.$size(), 1)); i = (function() {if ($truthy(last)) { return 0 } else { return $rb_plus(current_index, 1) }; return nil; })(); return links.$at(i); } else { i = $rb_minus(current_index, 1); return links.$at(i); }; return nil; })(); if ($truthy(link)) { href = link.$attr("href"); return $gvars.window.$location().$assign(href); } else { return nil }; }, $Pager_goto_link$10.$$arity = 1); (Opal.class_variable_set($nesting[0], '@@sidebar_links', nil)); Opal.def(self, '$sidebar_links', $Pager_sidebar_links$11 = function $$sidebar_links() { var $a, self = this; if ($truthy((($a = $nesting[0].$$cvars['@@sidebar_links']) == null ? nil : $a))) { return (($a = $nesting[0].$$cvars['@@sidebar_links']) == null ? nil : $a)}; return (Opal.class_variable_set($nesting[0], '@@sidebar_links', self.sidebar.$find(".content-nav a"))); }, $Pager_sidebar_links$11.$$arity = 0); return (Opal.def(self, '$find_current', $Pager_find_current$12 = function $$find_current() { var $$13, self = this, current_location = nil, links = nil; if ($gvars.window == null) $gvars.window = nil; current_location = $gvars.window.$location().$path(); links = self.$sidebar_links(); return $send(links, 'select', [], ($$13 = function(l){var self = $$13.$$s || this; if (l == null) { l = nil; }; return l.$attr("href")['$=='](current_location);}, $$13.$$s = self, $$13.$$arity = 1, $$13)).$first(); }, $Pager_find_current$12.$$arity = 0), nil) && 'find_current'; })($nesting[0], null, $nesting) }; /* Generated by Opal 1.0.3 */ (function(Opal) { var $$1, self = Opal.top, $nesting = [], nil = Opal.nil, $$$ = Opal.const_get_qualified, $$ = Opal.const_get_relative, $breaker = Opal.breaker, $slice = Opal.slice, $send = Opal.send; Opal.add_stubs(['$require', '$ready?', '$setup']); self.$require("opal"); self.$require("opal-jquery"); self.$require("browser"); self.$require("browser/location"); self.$require("native"); self.$require("sidebar"); self.$require("pager"); return $send($$($nesting, 'Document'), 'ready?', [], ($$1 = function(){var self = $$1.$$s || this; $$($nesting, 'Sidebar').$setup(); return $$($nesting, 'Pager').$setup();}, $$1.$$s = self, $$1.$$arity = 0, $$1)); })(Opal);