carats 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2 -0
- data/LICENSE +5 -0
- data/README +67 -0
- data/Reapfile +72 -0
- data/ToDo +24 -0
- data/bench/b_harray.rb +49 -0
- data/bench/b_range.rb +64 -0
- data/demo/ansicolor/cdiff.rb +20 -0
- data/demo/ansicolor/example.rb +82 -0
- data/demo/io-reactor/chatserver.rb +347 -0
- data/doc/classes/Array.html +172 -0
- data/doc/classes/BBCode.html +638 -0
- data/doc/classes/BinaryReader.html +675 -0
- data/doc/classes/Binding.html +223 -0
- data/doc/classes/ByteOrder.html +284 -0
- data/doc/classes/Class.html +189 -0
- data/doc/classes/Constant.html +785 -0
- data/doc/classes/Constant/CGS.html +609 -0
- data/doc/classes/Continuation.html +113 -0
- data/doc/classes/Coroutine.html +387 -0
- data/doc/classes/CountingSemaphore.html +337 -0
- data/doc/classes/CrossCase.html +561 -0
- data/doc/classes/DynamicMixin.html +185 -0
- data/doc/classes/EnumerableWithArgs.html +550 -0
- data/doc/classes/Expect.html +428 -0
- data/doc/classes/Expect/DefaultChain.html +113 -0
- data/doc/classes/Expect/SeparatedPattern.html +223 -0
- data/doc/classes/Expect/Timeout.html +167 -0
- data/doc/classes/Expect/UnmatchedMessage.html +160 -0
- data/doc/classes/FileList.html +833 -0
- data/doc/classes/FloatString.html +534 -0
- data/doc/classes/Functor.html +211 -0
- data/doc/classes/HArray.html +1872 -0
- data/doc/classes/HTML.html +328 -0
- data/doc/classes/Heap.html +683 -0
- data/doc/classes/Heap/EmptyHeapException.html +111 -0
- data/doc/classes/Heap/Max.html +176 -0
- data/doc/classes/Heap/Min.html +176 -0
- data/doc/classes/IO.html +108 -0
- data/doc/classes/IO/Reactor.html +790 -0
- data/doc/classes/IO/Redirect.html +289 -0
- data/doc/classes/Infinity.html +320 -0
- data/doc/classes/Interval.html +1014 -0
- data/doc/classes/InvalidNackError.html +161 -0
- data/doc/classes/Kernel.html +204 -0
- data/doc/classes/Lisp.html +1132 -0
- data/doc/classes/Lisp/DottedPair.html +379 -0
- data/doc/classes/Lisp/Format.html +178 -0
- data/doc/classes/Lisp/Format/ArgumentError.html +126 -0
- data/doc/classes/Lisp/Format/Directives.html +155 -0
- data/doc/classes/Lisp/Format/Directives/ArgJump.html +178 -0
- data/doc/classes/Lisp/Format/Directives/Ascii.html +119 -0
- data/doc/classes/Lisp/Format/Directives/BeginCaseConversion.html +185 -0
- data/doc/classes/Lisp/Format/Directives/BeginConditional.html +307 -0
- data/doc/classes/Lisp/Format/Directives/BeginIteration.html +338 -0
- data/doc/classes/Lisp/Format/Directives/Binary.html +157 -0
- data/doc/classes/Lisp/Format/Directives/Character.html +228 -0
- data/doc/classes/Lisp/Format/Directives/CharacterDirective.html +203 -0
- data/doc/classes/Lisp/Format/Directives/ClauseSeparator.html +166 -0
- data/doc/classes/Lisp/Format/Directives/Decimal.html +119 -0
- data/doc/classes/Lisp/Format/Directives/Directive.html +397 -0
- data/doc/classes/Lisp/Format/Directives/DollarFP.html +205 -0
- data/doc/classes/Lisp/Format/Directives/EndCaseConversion.html +174 -0
- data/doc/classes/Lisp/Format/Directives/EndConditional.html +159 -0
- data/doc/classes/Lisp/Format/Directives/EndIteration.html +163 -0
- data/doc/classes/Lisp/Format/Directives/ExpFP.html +252 -0
- data/doc/classes/Lisp/Format/Directives/FFFP.html +224 -0
- data/doc/classes/Lisp/Format/Directives/Factory.html +180 -0
- data/doc/classes/Lisp/Format/Directives/FreshLine.html +175 -0
- data/doc/classes/Lisp/Format/Directives/GeneralFP.html +265 -0
- data/doc/classes/Lisp/Format/Directives/Hexadecimal.html +157 -0
- data/doc/classes/Lisp/Format/Directives/Indirection.html +183 -0
- data/doc/classes/Lisp/Format/Directives/Literal.html +187 -0
- data/doc/classes/Lisp/Format/Directives/NewLine.html +158 -0
- data/doc/classes/Lisp/Format/Directives/NewPage.html +158 -0
- data/doc/classes/Lisp/Format/Directives/Number.html +243 -0
- data/doc/classes/Lisp/Format/Directives/Octal.html +157 -0
- data/doc/classes/Lisp/Format/Directives/Plural.html +177 -0
- data/doc/classes/Lisp/Format/Directives/Print.html +237 -0
- data/doc/classes/Lisp/Format/Directives/Radix.html +432 -0
- data/doc/classes/Lisp/Format/Directives/SExpression.html +157 -0
- data/doc/classes/Lisp/Format/Directives/SkipWhitespace.html +165 -0
- data/doc/classes/Lisp/Format/Directives/Tabulate.html +198 -0
- data/doc/classes/Lisp/Format/Directives/Tilde.html +158 -0
- data/doc/classes/Lisp/Format/Directives/UnknownDirectiveError.html +117 -0
- data/doc/classes/Lisp/Format/Formatter.html +193 -0
- data/doc/classes/Lisp/Format/IncompleteParameterError.html +119 -0
- data/doc/classes/Lisp/Format/IndexError.html +126 -0
- data/doc/classes/Lisp/Format/Lexer.html +479 -0
- data/doc/classes/Lisp/Format/MalformedError.html +119 -0
- data/doc/classes/Lisp/Format/MissingParameterError.html +119 -0
- data/doc/classes/Lisp/Format/ModifierError.html +119 -0
- data/doc/classes/Lisp/Format/Output.html +239 -0
- data/doc/classes/Lisp/Format/ParameterError.html +126 -0
- data/doc/classes/Lisp/Format/Parameters.html +123 -0
- data/doc/classes/Lisp/Format/Parameters/Argument.html +172 -0
- data/doc/classes/Lisp/Format/Parameters/ArgumentCount.html +159 -0
- data/doc/classes/Lisp/Format/Parameters/Character.html +119 -0
- data/doc/classes/Lisp/Format/Parameters/Default.html +120 -0
- data/doc/classes/Lisp/Format/Parameters/Integer.html +119 -0
- data/doc/classes/Lisp/Format/Parameters/Parameter.html +206 -0
- data/doc/classes/Lisp/Format/Parser.html +212 -0
- data/doc/classes/Lisp/Format/Positioned.html +166 -0
- data/doc/classes/Lisp/Format/State.html +455 -0
- data/doc/classes/Lisp/Format/SyntaxError.html +126 -0
- data/doc/classes/Method.html +274 -0
- data/doc/classes/Method/DuckHunter.html +281 -0
- data/doc/classes/Module.html +709 -0
- data/doc/classes/Multiton.html +284 -0
- data/doc/classes/Multiton/New.html +164 -0
- data/doc/classes/Multiton/Semi.html +155 -0
- data/doc/classes/NackClass.html +322 -0
- data/doc/classes/NilClass.html +231 -0
- data/doc/classes/NilComparable.html +179 -0
- data/doc/classes/NotCopyable.html +273 -0
- data/doc/classes/Object.html +261 -0
- data/doc/classes/OpenStructable.html +346 -0
- data/doc/classes/OrderedHash.html +939 -0
- data/doc/classes/Parser.html +515 -0
- data/doc/classes/Parser/Main.html +178 -0
- data/doc/classes/Parser/Marker.html +475 -0
- data/doc/classes/Parser/Registry.html +354 -0
- data/doc/classes/Parser/Token.html +399 -0
- data/doc/classes/Parser/UnitToken.html +222 -0
- data/doc/classes/Ref.html +230 -0
- data/doc/classes/SimpleStringIO.html +183 -0
- data/doc/classes/StaticHash.html +202 -0
- data/doc/classes/String.html +172 -0
- data/doc/classes/Struct.html +181 -0
- data/doc/classes/SuperStruct.html +382 -0
- data/doc/classes/Term.html +156 -0
- data/doc/classes/Term/ANSIColor.html +185 -0
- data/doc/classes/Text.html +138 -0
- data/doc/classes/Text/Soundex.html +222 -0
- data/doc/classes/TextTagIterator.html +911 -0
- data/doc/classes/Time.html +119 -0
- data/doc/classes/Time/Limit.html +303 -0
- data/doc/classes/Time/Limit/Dummy.html +181 -0
- data/doc/classes/Timer.html +351 -0
- data/doc/classes/TracePoint.html +532 -0
- data/doc/classes/Tuple.html +178 -0
- data/doc/classes/Uninheritable.html +213 -0
- data/doc/classes/Version.html +783 -0
- data/doc/created.rid +1 -0
- data/doc/files/LICENSE.html +113 -0
- data/doc/files/README.html +201 -0
- data/doc/files/lib/carat/1st_rb.html +107 -0
- data/doc/files/lib/carat/ansicolor_rb.html +146 -0
- data/doc/files/lib/carat/attr_rb.html +101 -0
- data/doc/files/lib/carat/bbcode_rb.html +152 -0
- data/doc/files/lib/carat/binaryreader_rb.html +114 -0
- data/doc/files/lib/carat/binding-of-caller_rb.html +108 -0
- data/doc/files/lib/carat/byteorder_rb.html +107 -0
- data/doc/files/lib/carat/constant_rb.html +167 -0
- data/doc/files/lib/carat/coroutine_rb.html +156 -0
- data/doc/files/lib/carat/crosscase_rb.html +224 -0
- data/doc/files/lib/carat/duckhunter_rb.html +165 -0
- data/doc/files/lib/carat/dynamic-mixin_rb.html +101 -0
- data/doc/files/lib/carat/enumerable-args_rb.html +140 -0
- data/doc/files/lib/carat/expect_rb.html +137 -0
- data/doc/files/lib/carat/filelist_rb.html +130 -0
- data/doc/files/lib/carat/floatstring_rb.html +126 -0
- data/doc/files/lib/carat/functor_rb.html +140 -0
- data/doc/files/lib/carat/harray_rb.html +128 -0
- data/doc/files/lib/carat/heap_rb.html +154 -0
- data/doc/files/lib/carat/html-helpers_rb.html +116 -0
- data/doc/files/lib/carat/infinity_rb.html +142 -0
- data/doc/files/lib/carat/init_rb.html +127 -0
- data/doc/files/lib/carat/interval_rb.html +162 -0
- data/doc/files/lib/carat/io-reactor_rb.html +211 -0
- data/doc/files/lib/carat/io-redirect_rb.html +132 -0
- data/doc/files/lib/carat/lisp-format_rb.html +187 -0
- data/doc/files/lib/carat/lisp_rb.html +152 -0
- data/doc/files/lib/carat/macro_rb.html +129 -0
- data/doc/files/lib/carat/multiton_rb.html +178 -0
- data/doc/files/lib/carat/nack_rb.html +193 -0
- data/doc/files/lib/carat/nil-comparable_rb.html +126 -0
- data/doc/files/lib/carat/nil-missing_rb.html +101 -0
- data/doc/files/lib/carat/notcopyable_rb.html +166 -0
- data/doc/files/lib/carat/orderedhash_rb.html +107 -0
- data/doc/files/lib/carat/ostructable_rb.html +157 -0
- data/doc/files/lib/carat/parser-old_rb.html +239 -0
- data/doc/files/lib/carat/parser_rb.html +244 -0
- data/doc/files/lib/carat/ref_rb.html +107 -0
- data/doc/files/lib/carat/semaphore_rb.html +132 -0
- data/doc/files/lib/carat/snapshot_rb.html +152 -0
- data/doc/files/lib/carat/soundex_rb.html +128 -0
- data/doc/files/lib/carat/sstruct_rb.html +142 -0
- data/doc/files/lib/carat/statichash_rb.html +150 -0
- data/doc/files/lib/carat/tagiter_rb.html +236 -0
- data/doc/files/lib/carat/timelimit_rb.html +136 -0
- data/doc/files/lib/carat/timer_rb.html +153 -0
- data/doc/files/lib/carat/tracepoint_rb.html +160 -0
- data/doc/files/lib/carat/tuple_rb.html +123 -0
- data/doc/files/lib/carat/uninheritable_rb.html +101 -0
- data/doc/files/lib/carat/version_rb.html +141 -0
- data/doc/fr_class_index.html +159 -0
- data/doc/fr_file_index.html +78 -0
- data/doc/fr_method_index.html +663 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/carat-dev/README +11 -0
- data/lib/carat-dev/access-blocks/access_blocks.rb +42 -0
- data/lib/carat-dev/association/association.rb +70 -0
- data/lib/carat-dev/blankslate/blankslate.rb +51 -0
- data/lib/carat-dev/breakpoint.rb +518 -0
- data/lib/carat-dev/class-constructor/constructor_methods.rb +78 -0
- data/lib/carat-dev/class-constructor/tc_constructor.rb +35 -0
- data/lib/carat-dev/closecall/closecall-test.rb +39 -0
- data/lib/carat-dev/closecall/closecall.rb +101 -0
- data/lib/carat-dev/commandrunner/commandrunner.rb +100 -0
- data/lib/carat-dev/conditional/conditionals.rb +106 -0
- data/lib/carat-dev/daemon/daemon.rb +70 -0
- data/lib/carat-dev/detach/detach.rb +363 -0
- data/lib/carat-dev/detach/tc_detach.rb +57 -0
- data/lib/carat-dev/import-module/import-module-0.81.tar.gz +0 -0
- data/lib/carat-dev/import-module/import-module-0.81/LICENSE +1 -0
- data/lib/carat-dev/import-module/import-module-0.81/Makefile +11 -0
- data/lib/carat-dev/import-module/import-module-0.81/README +4 -0
- data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-hash.rb +49 -0
- data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-pip.rb +71 -0
- data/lib/carat-dev/import-module/import-module-0.81/dev-lib/import-module-unbound-method.rb +36 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README-ja.html +293 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README-ja.rd +306 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README.html +290 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/README.rd +303 -0
- data/lib/carat-dev/import-module/import-module-0.81/doc/style.css +85 -0
- data/lib/carat-dev/import-module/import-module-0.81/install.rb +99 -0
- data/lib/carat-dev/import-module/import-module-0.81/lib/import-module-single-thread.rb +84 -0
- data/lib/carat-dev/import-module/import-module-0.81/lib/import-module.rb +493 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/Makefile +2 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test +91 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-import-module.rb +936 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-import_scope.rb +33 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-scope_import.rb +33 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test-time.rb +184 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/test.sh +91 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/time.rb +135 -0
- data/lib/carat-dev/import-module/import-module-0.81/test/times-do.sh +10 -0
- data/lib/carat-dev/interface_work/SCRAP/i-contracts.rb +37 -0
- data/lib/carat-dev/interface_work/SCRAP/interface.rb +105 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0.zip +0 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/CHANGES +3 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/MANIFEST +15 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/README +32 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/doc/interface.rd +73 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/doc/interface.txt +94 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/install.rb +16 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/lib/interface.rb +50 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/tc_interface.rb +51 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test.rb +29 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_instance.rb +24 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_sub.rb +29 -0
- data/lib/carat-dev/interface_work/SCRAP/j-interface/interface-0.1.0/test/test_unrequire.rb +28 -0
- data/lib/carat-dev/interface_work/contracts/contract.zip +0 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.html +376 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000001.html +23 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000002.html +18 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000003.html +19 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000004.html +29 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000005.html +18 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract.src/M000006.html +18 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractError.html +142 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractException.html +153 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Contract/ContractMismatch.html +125 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Module.html +157 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/classes/Module.src/M000007.html +112 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/created.rid +1 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/assertions_rb.html +109 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/exception_rb.html +108 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/integration_rb.html +108 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract/overrides_rb.html +109 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/files/lib/contract_rb.html +114 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/fr_class_index.html +31 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/fr_file_index.html +31 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/fr_method_index.html +33 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/index.html +24 -0
- data/lib/carat-dev/interface_work/contracts/contract/doc/rdoc-style.css +208 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract.rb +88 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/assertions.rb +37 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/exception.rb +92 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/integration.rb +132 -0
- data/lib/carat-dev/interface_work/contracts/contract/lib/contract/overrides.rb +32 -0
- data/lib/carat-dev/interface_work/must.rb +37 -0
- data/lib/carat-dev/interface_work/type.rb +232 -0
- data/lib/carat-dev/main/tc_toplevel.rb +23 -0
- data/lib/carat-dev/main/toplevel.rb +33 -0
- data/lib/carat-dev/main/toplevel_test.rb +24 -0
- data/lib/carat-dev/misc/1.rb +40 -0
- data/lib/carat-dev/misc/misc.rb +44 -0
- data/lib/carat-dev/misc/sys.rb +186 -0
- data/lib/carat-dev/misc/temp.rb +1 -0
- data/lib/carat-dev/misc/utils.rb +518 -0
- data/lib/carat-dev/predicate/predicate.rb +109 -0
- data/lib/carat-dev/predicate/predicate_test.rb +67 -0
- data/lib/carat-dev/premshree.rb +40 -0
- data/lib/carat-dev/priority-queue/pqueue.rb +183 -0
- data/lib/carat-dev/priority-queue/priorityqueue.rb +84 -0
- data/lib/carat-dev/quaternion/quaternion.rb +529 -0
- data/lib/carat-dev/range.rb +259 -0
- data/lib/carat-dev/system/rubyinfo.rb +75 -0
- data/lib/carat-dev/system/system.rb +105 -0
- data/lib/carat-dev/tc_range.rb +118 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.html +291 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000001.html +26 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000002.html +19 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000003.html +18 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000004.html +18 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000005.html +21 -0
- data/lib/carat-dev/timer/timer-doc/classes/Timer.src/M000006.html +23 -0
- data/lib/carat-dev/timer/timer-doc/created.rid +1 -0
- data/lib/carat-dev/timer/timer-doc/files/timer_rb.html +144 -0
- data/lib/carat-dev/timer/timer-doc/fr_class_index.html +27 -0
- data/lib/carat-dev/timer/timer-doc/fr_file_index.html +27 -0
- data/lib/carat-dev/timer/timer-doc/fr_method_index.html +32 -0
- data/lib/carat-dev/timer/timer-doc/index.html +24 -0
- data/lib/carat-dev/timer/timer-doc/rdoc-style.css +208 -0
- data/lib/carat-dev/timer/timer.rb +160 -0
- data/lib/carat-dev/vars/vars.rb +62 -0
- data/lib/carat/1st.rb +58 -0
- data/lib/carat/ansicolor.rb +122 -0
- data/lib/carat/attr.rb +342 -0
- data/lib/carat/bbcode.rb +352 -0
- data/lib/carat/binaryreader.rb +170 -0
- data/lib/carat/binding-of-caller.rb +83 -0
- data/lib/carat/byteorder.rb +34 -0
- data/lib/carat/constant.rb +287 -0
- data/lib/carat/coroutine.rb +102 -0
- data/lib/carat/crosscase.rb +309 -0
- data/lib/carat/duckhunter.rb +158 -0
- data/lib/carat/dynamic-mixin.rb +71 -0
- data/lib/carat/enumerable-args.rb +125 -0
- data/lib/carat/expect.rb +192 -0
- data/lib/carat/filelist.rb +277 -0
- data/lib/carat/floatstring.rb +153 -0
- data/lib/carat/functor.rb +41 -0
- data/lib/carat/harray.rb +507 -0
- data/lib/carat/heap.rb +193 -0
- data/lib/carat/html-helpers.rb +82 -0
- data/lib/carat/infinity.rb +61 -0
- data/lib/carat/init.rb +33 -0
- data/lib/carat/interval.rb +248 -0
- data/lib/carat/io-reactor.rb +657 -0
- data/lib/carat/io-redirect.rb +99 -0
- data/lib/carat/lisp-format.rb +1832 -0
- data/lib/carat/lisp.rb +336 -0
- data/lib/carat/macro.rb +68 -0
- data/lib/carat/multiton.rb +153 -0
- data/lib/carat/nack.rb +115 -0
- data/lib/carat/nil-comparable.rb +67 -0
- data/lib/carat/nil-missing.rb +12 -0
- data/lib/carat/notcopyable.rb +68 -0
- data/lib/carat/orderedhash.rb +249 -0
- data/lib/carat/ostructable.rb +138 -0
- data/lib/carat/parser-old.rb +350 -0
- data/lib/carat/parser.rb +393 -0
- data/lib/carat/ref.rb +31 -0
- data/lib/carat/semaphore.rb +69 -0
- data/lib/carat/snapshot.rb +94 -0
- data/lib/carat/soundex.rb +104 -0
- data/lib/carat/sstruct.rb +223 -0
- data/lib/carat/statichash.rb +49 -0
- data/lib/carat/tagiter.rb +345 -0
- data/lib/carat/timelimit.rb +114 -0
- data/lib/carat/timer.rb +99 -0
- data/lib/carat/tracepoint.rb +154 -0
- data/lib/carat/tuple.rb +31 -0
- data/lib/carat/uninheritable.rb +68 -0
- data/lib/carat/version.rb +147 -0
- data/pub/doc/sstruct.txt +204 -0
- data/pub/doc/tagiter.html +145 -0
- data/setup.rb +1361 -0
- data/test/fixtures/filelist/testfile.txt +1 -0
- data/test/fixtures/filelist/testfile2.txt +1 -0
- data/test/tc_1st.rb +16 -0
- data/test/tc_ansicolor.rb +23 -0
- data/test/tc_attr.rb +46 -0
- data/test/tc_bbcode.rb +20 -0
- data/test/tc_binaryreader.rb +14 -0
- data/test/tc_binding_of_caller.rb +2 -0
- data/test/tc_byteorder.rb +41 -0
- data/test/tc_constant.rb +12 -0
- data/test/tc_coroutine.rb +50 -0
- data/test/tc_crosscase.rb +33 -0
- data/test/tc_duckhunter.rb +37 -0
- data/test/tc_dynamic-mixin.rb +66 -0
- data/test/tc_enumerable-args.rb +66 -0
- data/test/tc_expect.rb +83 -0
- data/test/tc_filelist.rb +17 -0
- data/test/tc_floatstring.rb +22 -0
- data/test/tc_functor.rb +18 -0
- data/test/tc_harray.rb +280 -0
- data/test/tc_heap.rb +6 -0
- data/test/tc_infinity.rb +23 -0
- data/test/tc_init.rb +29 -0
- data/test/tc_interval.rb +153 -0
- data/test/tc_io-reactor.rb +5 -0
- data/test/tc_io-redirect.rb +5 -0
- data/test/tc_lisp-format.rb +24 -0
- data/test/tc_lisp.rb +32 -0
- data/test/tc_macro.rb +48 -0
- data/test/tc_multiton.rb +188 -0
- data/test/tc_nack.rb +31 -0
- data/test/tc_nil-as-emptiness.rb +19 -0
- data/test/tc_nil-comparable.rb +29 -0
- data/test/tc_nil-missing.rb +0 -0
- data/test/tc_notcopyable.rb +64 -0
- data/test/tc_orderedhash.rb +36 -0
- data/test/tc_ostructable.rb +31 -0
- data/test/tc_semaphore.rb +5 -0
- data/test/tc_snapshot.rb +20 -0
- data/test/tc_soundex.rb +19 -0
- data/test/tc_sstruct.rb +313 -0
- data/test/tc_statichash.rb +24 -0
- data/test/tc_tagiter.rb +80 -0
- data/test/tc_timelimit.rb +47 -0
- data/test/tc_timer.rb +35 -0
- data/test/tc_tracepoint.rb +10 -0
- data/test/tc_tuple.rb +25 -0
- data/test/tc_uninheritable.rb +33 -0
- data/test/tc_version.rb +90 -0
- metadata +531 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
begin
|
2
|
+
require 'simplecc'
|
3
|
+
rescue LoadError
|
4
|
+
class Continuation; end # :nodoc: # for RDoc
|
5
|
+
def Continuation.create(*args, &block) # :nodoc:
|
6
|
+
cc = nil; result = callcc {|c| cc = c; block.call(cc) if block and args.empty?}
|
7
|
+
result ||= args
|
8
|
+
return *[cc, *result]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Binding; end # for RDoc
|
13
|
+
# This method returns the binding of the method that called your
|
14
|
+
# method. It will raise an Exception when you're not inside a method.
|
15
|
+
#
|
16
|
+
# It's used like this:
|
17
|
+
# def inc_counter(amount = 1)
|
18
|
+
# Binding.of_caller do |binding|
|
19
|
+
# # Create a lambda that will increase the variable 'counter'
|
20
|
+
# # in the caller of this method when called.
|
21
|
+
# inc = eval("lambda { |arg| counter += arg }", binding)
|
22
|
+
# # We can refer to amount from inside this block safely.
|
23
|
+
# inc.call(amount)
|
24
|
+
# end
|
25
|
+
# # No other statements can go here. Put them inside the block.
|
26
|
+
# end
|
27
|
+
# counter = 0
|
28
|
+
# 2.times { inc_counter }
|
29
|
+
# counter # => 2
|
30
|
+
#
|
31
|
+
# Binding.of_caller must be the last statement in the method.
|
32
|
+
# This means that you will have to put everything you want to
|
33
|
+
# do after the call to Binding.of_caller into the block of it.
|
34
|
+
# This should be no problem however, because Ruby has closures.
|
35
|
+
# If you don't do this an Exception will be raised. Because of
|
36
|
+
# the way that Binding.of_caller is implemented it has to be
|
37
|
+
# done this way.
|
38
|
+
def Binding.of_caller(&block)
|
39
|
+
old_critical = Thread.critical
|
40
|
+
Thread.critical = true
|
41
|
+
count = 0
|
42
|
+
cc, result, error, extra_data = Continuation.create(nil, nil)
|
43
|
+
error.call if error
|
44
|
+
|
45
|
+
tracer = lambda do |*args|
|
46
|
+
type, context, extra_data = args[0], args[4], args
|
47
|
+
if type == "return"
|
48
|
+
count += 1
|
49
|
+
# First this method and then calling one will return --
|
50
|
+
# the trace event of the second event gets the context
|
51
|
+
# of the method which called the method that called this
|
52
|
+
# method.
|
53
|
+
if count == 2
|
54
|
+
# It would be nice if we could restore the trace_func
|
55
|
+
# that was set before we swapped in our own one, but
|
56
|
+
# this is impossible without overloading set_trace_func
|
57
|
+
# in current Ruby.
|
58
|
+
set_trace_func(nil)
|
59
|
+
cc.call(eval("binding", context), nil, extra_data)
|
60
|
+
end
|
61
|
+
elsif type == "line" then
|
62
|
+
nil
|
63
|
+
elsif type == "c-return" and extra_data[3] == :set_trace_func then
|
64
|
+
nil
|
65
|
+
else
|
66
|
+
set_trace_func(nil)
|
67
|
+
error_msg = "Binding.of_caller used in non-method context or " +
|
68
|
+
"trailing statements of method using it aren't in the block."
|
69
|
+
cc.call(nil, lambda { raise(ArgumentError, error_msg) }, nil)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
unless result
|
74
|
+
set_trace_func(tracer)
|
75
|
+
return nil
|
76
|
+
else
|
77
|
+
Thread.critical = old_critical
|
78
|
+
case block.arity
|
79
|
+
when 1 then yield(result)
|
80
|
+
else yield(result, extra_data)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# by Michael Neumann
|
2
|
+
|
3
|
+
module ByteOrder
|
4
|
+
Native = :Native
|
5
|
+
BigEndian = Big = Network = :BigEndian
|
6
|
+
LittleEndian = Little = :LittleEndian
|
7
|
+
|
8
|
+
# examines the byte order of the underlying machine
|
9
|
+
def byte_order
|
10
|
+
if [0x12345678].pack("L") == "\x12\x34\x56\x78"
|
11
|
+
BigEndian
|
12
|
+
else
|
13
|
+
LittleEndian
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
alias byteorder byte_order
|
18
|
+
|
19
|
+
def little_endian?
|
20
|
+
byte_order == LittleEndian
|
21
|
+
end
|
22
|
+
|
23
|
+
def big_endian?
|
24
|
+
byte_order == BigEndian
|
25
|
+
end
|
26
|
+
|
27
|
+
alias little? little_endian?
|
28
|
+
alias big? big_endian?
|
29
|
+
alias network? big_endian?
|
30
|
+
|
31
|
+
module_function :byte_order, :byteorder
|
32
|
+
module_function :little_endian?, :little?
|
33
|
+
module_function :big_endian?, :big?, :network?
|
34
|
+
end
|
@@ -0,0 +1,287 @@
|
|
1
|
+
# $Id: constants.rb,v 1.0.2 2004/11/30 transami Exp $
|
2
|
+
=begin rdoc
|
3
|
+
|
4
|
+
= Constant
|
5
|
+
|
6
|
+
Large assortment of real world contants.
|
7
|
+
|
8
|
+
== Synopsis
|
9
|
+
|
10
|
+
require 'trix/constant'
|
11
|
+
|
12
|
+
puts CONSTANT::SPEED_OF_LIGHT
|
13
|
+
|
14
|
+
== Legal
|
15
|
+
|
16
|
+
Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough
|
17
|
+
Copyright (C) 2003 Daniel Carrera
|
18
|
+
|
19
|
+
This program is free software; you can redistribute it and/or modify
|
20
|
+
it under the terms of the GNU General Public License as published by
|
21
|
+
the Free Software Foundation; either version 2 of the License, or (at
|
22
|
+
your option) any later version.
|
23
|
+
|
24
|
+
This program is distributed in the hope that it will be useful, but
|
25
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
26
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
27
|
+
General Public License for more details.
|
28
|
+
|
29
|
+
You should have received a copy of the GNU General Public License
|
30
|
+
along with this program; if not, write to the Free Software
|
31
|
+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
32
|
+
|
33
|
+
== History
|
34
|
+
|
35
|
+
* v 1.0.2 2004/12/01 transami
|
36
|
+
** Ported to Trix library.
|
37
|
+
* v 1.0.1 2003 Daniel
|
38
|
+
** Made the installation script a bit nicer.
|
39
|
+
** Reorganized the documentation.
|
40
|
+
** Added a few aliases (e.g. ATOMIC_MASS == UNIFIED_ATOMIC_MASS) and changed a few constant names.
|
41
|
+
* v 1.0.0 2000 Brian
|
42
|
+
** First stable version.
|
43
|
+
** Added a test-suite, documentation and installation script.
|
44
|
+
** There should be no bugs at this point.
|
45
|
+
|
46
|
+
=end
|
47
|
+
|
48
|
+
module Constant
|
49
|
+
|
50
|
+
VERSION = "1.0.2"
|
51
|
+
|
52
|
+
#
|
53
|
+
# Unit-less constants.
|
54
|
+
#
|
55
|
+
|
56
|
+
FINE_STRUCTURE = 7.297352533e-3 # 1
|
57
|
+
AVOGADRO = 6.02214199e23 # 1
|
58
|
+
YOTTA = 1e24 # 1
|
59
|
+
ZETTA = 1e21 # 1
|
60
|
+
EXA = 1e18 # 1
|
61
|
+
PETA = 1e15 # 1
|
62
|
+
TERA = 1e12 # 1
|
63
|
+
GIGA = 1e9 # 1
|
64
|
+
MEGA = 1e6 # 1
|
65
|
+
KILO = 1e3 # 1
|
66
|
+
MILLI = 1e-3 # 1
|
67
|
+
MICRO = 1e-6 # 1
|
68
|
+
NANO = 1e-9 # 1
|
69
|
+
PICO = 1e-12 # 1
|
70
|
+
FEMTO = 1e-15 # 1
|
71
|
+
ATTO = 1e-18 # 1
|
72
|
+
ZEPTO = 1e-21 # 1
|
73
|
+
YOCTO = 1e-24 # 1
|
74
|
+
|
75
|
+
#
|
76
|
+
# Constants in the MKS system (meters, kg, sec)
|
77
|
+
#
|
78
|
+
|
79
|
+
SPEED_OF_LIGHT = 2.99792458e8 # m / s
|
80
|
+
GRAV_CONSTANT = 6.673e-11 # m^3 / kg s^2
|
81
|
+
PLANCKS_CONSTANT_H = 6.62606876e-34 # kg m^2 / s
|
82
|
+
PLANCKS_CONSTANT_HBAR = 1.05457159642e-34 # kg m^2 / s
|
83
|
+
VACUUM_PERMEABILITY = 1.25663706144e-6 # kg m / A^2 s^2
|
84
|
+
ASTRONOMICAL_UNIT = 1.49597870691e11 # m
|
85
|
+
LIGHT_YEAR = 9.46053620707e15 # m
|
86
|
+
PARSEC = 3.08567758135e16 # m
|
87
|
+
GRAV_ACCEL = 9.80665e0 # m / s^2
|
88
|
+
ELECTRON_VOLT = 1.602176462e-19 # kg m^2 / s^2
|
89
|
+
MASS_ELECTRON = 9.10938188e-31 # kg
|
90
|
+
MASS_MUON = 1.88353109e-28 # kg
|
91
|
+
MASS_PROTON = 1.67262158e-27 # kg
|
92
|
+
MASS_NEUTRON = 1.67492716e-27 # kg
|
93
|
+
RYDBERG = 2.17987190389e-18 # kg m^2 / s^2
|
94
|
+
BOLTZMANN = 1.3806503e-23 # kg m^2 / K s^2
|
95
|
+
BOHR_MAGNETON = 9.27400899e-24 # A m^2
|
96
|
+
NUCLEAR_MAGNETON = 5.05078317e-27 # A m^2
|
97
|
+
ELECTRON_MAGNETIC_MOMENT = 9.28476362e-24 # A m^2
|
98
|
+
PROTON_MAGNETIC_MOMENT = 1.410606633e-26 # A m^2
|
99
|
+
MOLAR_GAS = 8.314472e0 # kg m^2 / K mol s^2
|
100
|
+
STANDARD_GAS_VOLUME = 2.2710981e-2 # m^3 / mol
|
101
|
+
MINUTE = 6e1 # s
|
102
|
+
HOUR = 3.6e3 # s
|
103
|
+
DAY = 8.64e4 # s
|
104
|
+
WEEK = 6.048e5 # s
|
105
|
+
INCH = 2.54e-2 # m
|
106
|
+
FOOT = 3.048e-1 # m
|
107
|
+
YARD = 9.144e-1 # m
|
108
|
+
MILE = 1.609344e3 # m
|
109
|
+
NAUTICAL_MILE = 1.852e3 # m
|
110
|
+
FATHOM = 1.8288e0 # m
|
111
|
+
MIL = 2.54e-5 # m
|
112
|
+
POINT = 3.52777777778e-4 # m
|
113
|
+
TEXPOINT = 3.51459803515e-4 # m
|
114
|
+
MICRON = 1e-6 # m
|
115
|
+
ANGSTROM = 1e-10 # m
|
116
|
+
HECTARE = 1e4 # m^2
|
117
|
+
ACRE = 4.04685642241e3 # m^2
|
118
|
+
BARN = 1e-28 # m^2
|
119
|
+
LITER = 1e-3 # m^3
|
120
|
+
US_GALLON = 3.78541178402e-3 # m^3
|
121
|
+
QUART = 9.46352946004e-4 # m^3
|
122
|
+
PINT = 4.73176473002e-4 # m^3
|
123
|
+
CUP = 2.36588236501e-4 # m^3
|
124
|
+
FLUID_OUNCE = 2.95735295626e-5 # m^3
|
125
|
+
TABLESPOON = 1.47867647813e-5 # m^3
|
126
|
+
TEASPOON = 4.92892159375e-6 # m^3
|
127
|
+
CANADIAN_GALLON = 4.54609e-3 # m^3
|
128
|
+
UK_GALLON = 4.546092e-3 # m^3
|
129
|
+
MILES_PER_HOUR = 4.4704e-1 # m / s
|
130
|
+
KILOMETERS_PER_HOUR = 2.77777777778e-1 # m / s
|
131
|
+
KNOT = 5.14444444444e-1 # m / s
|
132
|
+
POUND_MASS = 4.5359237e-1 # kg
|
133
|
+
OUNCE_MASS = 2.8349523125e-2 # kg
|
134
|
+
TON = 9.0718474e2 # kg
|
135
|
+
METRIC_TON = 1e3 # kg
|
136
|
+
UK_TON = 1.0160469088e3 # kg
|
137
|
+
TROY_OUNCE = 3.1103475e-2 # kg
|
138
|
+
CARAT = 2e-4 # kg
|
139
|
+
UNIFIED_ATOMIC_MASS = 1.66053873e-27 # kg
|
140
|
+
ATOMIC_MASS = 1.66053873e-27 # kg
|
141
|
+
GRAM_FORCE = 9.80665e-3 # kg m / s^2
|
142
|
+
POUND_FORCE = 4.44822161526e0 # kg m / s^2
|
143
|
+
KILOPOUND_FORCE = 4.44822161526e3 # kg m / s^2
|
144
|
+
POUNDAL = 1.38255e-1 # kg m / s^2
|
145
|
+
CALORIE = 4.1868e0 # kg m^2 / s^2
|
146
|
+
BTU = 1.05505585262e3 # kg m^2 / s^2
|
147
|
+
THERM = 1.05506e8 # kg m^2 / s^2
|
148
|
+
HORSEPOWER = 7.457e2 # kg m^2 / s^3
|
149
|
+
BAR = 1e5 # kg / m s^2
|
150
|
+
STD_ATMOSPHERE = 1.01325e5 # kg / m s^2
|
151
|
+
TORR = 1.33322368421e2 # kg / m s^2
|
152
|
+
METER_OF_MERCURY = 1.33322368421e5 # kg / m s^2
|
153
|
+
INCH_OF_MERCURY = 3.38638815789e3 # kg / m s^2
|
154
|
+
INCH_OF_WATER = 2.490889e2 # kg / m s^2
|
155
|
+
PSI = 6.89475729317e3 # kg / m s^2
|
156
|
+
POISE = 1e-1 # kg m^-1 s^-1
|
157
|
+
STOKES = 1e-4 # m^2 / s
|
158
|
+
FARADAY = 9.6485341472e4 # A s / mol
|
159
|
+
ELECTRON_CHARGE = 1.602176462e-19 # A s
|
160
|
+
GAUSS = 1e-4 # kg / A s^2
|
161
|
+
STILB = 1e4 # cd / m^2
|
162
|
+
LUMEN = 1e0 # cd sr
|
163
|
+
LUX = 1e0 # cd sr / m^2
|
164
|
+
PHOT = 1e4 # cd sr / m^2
|
165
|
+
FOOTCANDLE = 1.076e1 # cd sr / m^2
|
166
|
+
LAMBERT = 1e4 # cd sr / m^2
|
167
|
+
FOOTLAMBERT = 1.07639104e1 # cd sr / m^2
|
168
|
+
CURIE = 3.7e10 # 1 / s
|
169
|
+
ROENTGEN = 2.58e-4 # A s / kg
|
170
|
+
RAD = 1e-2 # m^2 / s^2
|
171
|
+
SOLAR_MASS = 1.98892e30 # kg
|
172
|
+
BOHR_RADIUS = 5.291772083e-11 # m
|
173
|
+
VACUUM_PERMITTIVITY = 8.854187817e-12 # A^2 s^4 / kg m^3
|
174
|
+
NEWTON = 1e0 # kg m / s^2
|
175
|
+
DYNE = 1e-5 # kg m / s^2
|
176
|
+
JOULE = 1e0 # kg m^2 / s^2
|
177
|
+
ERG = 1e-7 # kg m^2 / s^2
|
178
|
+
|
179
|
+
#
|
180
|
+
# Constants in the CGS system (cm, kg, s)
|
181
|
+
#
|
182
|
+
|
183
|
+
module CGS
|
184
|
+
|
185
|
+
SPEED_OF_LIGHT = 2.99792458e10 # cm / s
|
186
|
+
GRAVITATIONAL_CONSTANT = 6.673e-8 # cm^3 / g s^2
|
187
|
+
PLANCKS_CONSTANT_H = 6.62606876e-27 # g cm^2 / s
|
188
|
+
PLANCKS_CONSTANT_HBAR = 1.05457159642e-27 # g cm^2 / s
|
189
|
+
VACUUM_PERMEABILITY = 1.25663706144e-1 # cm g / A^2 s^2
|
190
|
+
ASTRONOMICAL_UNIT = 1.49597870691e13 # cm
|
191
|
+
LIGHT_YEAR = 9.46053620707e17 # cm
|
192
|
+
PARSEC = 3.08567758135e18 # cm
|
193
|
+
GRAV_ACCEL = 9.80665e2 # cm / s^2
|
194
|
+
ELECTRON_VOLT = 1.602176462e-12 # g cm^2 / s^2
|
195
|
+
MASS_ELECTRON = 9.10938188e-28 # g
|
196
|
+
MASS_MUON = 1.88353109e-25 # g
|
197
|
+
MASS_PROTON = 1.67262158e-24 # g
|
198
|
+
MASS_NEUTRON = 1.67492716e-24 # g
|
199
|
+
RYDBERG = 2.17987190389e-11 # g cm^2 / s^2
|
200
|
+
BOLTZMANN = 1.3806503e-16 # g cm^2 / K s^2
|
201
|
+
BOHR_MAGNETON = 9.27400899e-20 # A cm^2
|
202
|
+
NUCLEAR_MAGNETON = 5.05078317e-23 # A cm^2
|
203
|
+
ELECTRON_MAGNETIC_MOMENT = 9.28476362e-20 # A cm^2
|
204
|
+
PROTON_MAGNETIC_MOMENT = 1.410606633e-22 # A cm^2
|
205
|
+
MOLAR_GAS = 8.314472e7 # g cm^2 / K mol s^2
|
206
|
+
STD_GAS_VOLUME = 2.2710981e4 # cm^3 / mol
|
207
|
+
MINUTE = 6e1 # s
|
208
|
+
HOUR = 3.6e3 # s
|
209
|
+
DAY = 8.64e4 # s
|
210
|
+
WEEK = 6.048e5 # s
|
211
|
+
INCH = 2.54e0 # cm
|
212
|
+
FOOT = 3.048e1 # cm
|
213
|
+
YARD = 9.144e1 # cm
|
214
|
+
MILE = 1.609344e5 # cm
|
215
|
+
NAUTICAL_MILE = 1.852e5 # cm
|
216
|
+
FATHOM = 1.8288e2 # cm
|
217
|
+
MIL = 2.54e-3 # cm
|
218
|
+
POINT = 3.52777777778e-2 # cm
|
219
|
+
TEXPOINT = 3.51459803515e-2 # cm
|
220
|
+
MICRON = 1e-4 # cm
|
221
|
+
ANGSTROM = 1e-8 # cm
|
222
|
+
HECTARE = 1e8 # cm^2
|
223
|
+
ACRE = 4.04685642241e7 # cm^2
|
224
|
+
BARN = 1e-24 # cm^2
|
225
|
+
LITER = 1e3 # cm^3
|
226
|
+
US_GALLON = 3.78541178402e3 # cm^3
|
227
|
+
QUART = 9.46352946004e2 # cm^3
|
228
|
+
PINT = 4.73176473002e2 # cm^3
|
229
|
+
CUP = 2.36588236501e2 # cm^3
|
230
|
+
FLUID_OUNCE = 2.95735295626e1 # cm^3
|
231
|
+
TABLESPOON = 1.47867647813e1 # cm^3
|
232
|
+
TEASPOON = 4.92892159375e0 # cm^3
|
233
|
+
CANADIAN_GALLON = 4.54609e3 # cm^3
|
234
|
+
UK_GALLON = 4.546092e3 # cm^3
|
235
|
+
MILES_PER_HOUR = 4.4704e1 # cm / s
|
236
|
+
KILOMETERS_PER_HOUR = 2.77777777778e1 # cm / s
|
237
|
+
KNOT = 5.14444444444e1 # cm / s
|
238
|
+
POUND_MASS = 4.5359237e2 # g
|
239
|
+
OUNCE_MASS = 2.8349523125e1 # g
|
240
|
+
TON = 9.0718474e5 # g
|
241
|
+
METRIC_TON = 1e6 # g
|
242
|
+
UK_TON = 1.0160469088e6 # g
|
243
|
+
TROY_OUNCE = 3.1103475e1 # g
|
244
|
+
CARAT = 2e-1 # g
|
245
|
+
UNIFIED_ATOMIC_MASS = 1.66053873e-24 # g
|
246
|
+
GRAM_FORCE = 9.80665e2 # cm g / s^2
|
247
|
+
POUND_FORCE = 4.44822161526e5 # cm g / s^2
|
248
|
+
KILOPOUND_FORCE = 4.44822161526e8 # cm g / s^2
|
249
|
+
POUNDAL = 1.38255e4 # cm g / s^2
|
250
|
+
CALORIE = 4.1868e7 # g cm^2 / s^2
|
251
|
+
BTU = 1.05505585262e10 # g cm^2 / s^2
|
252
|
+
THERM = 1.05506e15 # g cm^2 / s^2
|
253
|
+
HORSEPOWER = 7.457e9 # g cm^2 / s^3
|
254
|
+
BAR = 1e6 # g / cm s^2
|
255
|
+
STD_ATMOSPHERE = 1.01325e6 # g / cm s^2
|
256
|
+
TORR = 1.33322368421e3 # g / cm s^2
|
257
|
+
METER_OF_MERCURY = 1.33322368421e6 # g / cm s^2
|
258
|
+
INCH_OF_MERCURY = 3.38638815789e4 # g / cm s^2
|
259
|
+
INCH_OF_WATER = 2.490889e3 # g / cm s^2
|
260
|
+
PSI = 6.89475729317e4 # g / cm s^2
|
261
|
+
POISE = 1e0 # g / cm s
|
262
|
+
STOKES = 1e0 # cm^2 / s
|
263
|
+
FARADAY = 9.6485341472e4 # A s / mol
|
264
|
+
ELECTRON_CHARGE = 1.602176462e-19 # A s
|
265
|
+
GAUSS = 1e-1 # g / A s^2
|
266
|
+
STILB = 1e0 # cd / cm^2
|
267
|
+
LUMEN = 1e0 # cd sr
|
268
|
+
LUX = 1e-4 # cd sr / cm^2
|
269
|
+
PHOT = 1e0 # cd sr / cm^2
|
270
|
+
FOOTCANDLE = 1.076e-3 # cd sr / cm^2
|
271
|
+
LAMBERT = 1e0 # cd sr / cm^2
|
272
|
+
FOOTLAMBERT = 1.07639104e-3 # cd sr / cm^2
|
273
|
+
CURIE = 3.7e10 # 1 / s
|
274
|
+
ROENTGEN = 2.58e-7 # A s / g
|
275
|
+
RAD = 1e2 # cm^2 / s^2
|
276
|
+
SOLAR_MASS = 1.98892e33 # g
|
277
|
+
BOHR_RADIUS = 5.291772083e-9 # cm
|
278
|
+
VACUUM_PERMITTIVITY = 8.854187817e-21 # A^2 s^4 / g cm^3
|
279
|
+
NEWTON = 1e5 # cm g / s^2
|
280
|
+
DYNE = 1e0 # cm g / s^2
|
281
|
+
JOULE = 1e7 # g cm^2 / s^2
|
282
|
+
ERG = 1e0 # g cm^2 / s^2
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
|
3
|
+
= Coroutine
|
4
|
+
|
5
|
+
Coroutines are program components like subroutines. Coroutines are more generic and flexible than subroutines,
|
6
|
+
but are less widely used in practice. Coroutines were first introduced natively in Simula.
|
7
|
+
Coroutines are well suited for implementing more familiar program components such as cooperative tasks,
|
8
|
+
iterators, infinite lists, and pipes.
|
9
|
+
|
10
|
+
== Example
|
11
|
+
|
12
|
+
count = (ARGV.shift || 1000).to_i
|
13
|
+
input = (1..count).map { (rand * 10000).round.to_f / 100}
|
14
|
+
Producer = Coroutine.new do |me|
|
15
|
+
loop do
|
16
|
+
1.upto(6) do
|
17
|
+
me[:last_input] = input.shift
|
18
|
+
me.resume(Printer)
|
19
|
+
end
|
20
|
+
input.shift # discard every seventh input number
|
21
|
+
end
|
22
|
+
end
|
23
|
+
Printer = Coroutine.new do |me|
|
24
|
+
loop do
|
25
|
+
1.upto(8) do
|
26
|
+
me.resume(Producer)
|
27
|
+
if Producer[:last_input]
|
28
|
+
print Producer[:last_input], "\t"
|
29
|
+
Producer[:last_input] = nil
|
30
|
+
end
|
31
|
+
me.resume(Controller)
|
32
|
+
end
|
33
|
+
puts
|
34
|
+
end
|
35
|
+
end
|
36
|
+
Controller = Coroutine.new do |me|
|
37
|
+
until input.empty? do
|
38
|
+
me.resume(Printer)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
Controller.run
|
42
|
+
puts
|
43
|
+
|
44
|
+
== Author
|
45
|
+
|
46
|
+
* Florian Frank
|
47
|
+
|
48
|
+
== History
|
49
|
+
|
50
|
+
$Id: coroutine.rb,v 1.0.0 2004/12/01 transami Exp $
|
51
|
+
|
52
|
+
=end
|
53
|
+
|
54
|
+
class Coroutine
|
55
|
+
|
56
|
+
VERSION = "1.0.0"
|
57
|
+
|
58
|
+
def initialize(data = {})
|
59
|
+
@data = data
|
60
|
+
callcc do |@continue|
|
61
|
+
return
|
62
|
+
end
|
63
|
+
yield self
|
64
|
+
stop
|
65
|
+
end
|
66
|
+
|
67
|
+
attr_reader :stopped
|
68
|
+
|
69
|
+
def run
|
70
|
+
callcc do |@stopped|
|
71
|
+
continue
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def stop
|
76
|
+
@stopped.call
|
77
|
+
end
|
78
|
+
|
79
|
+
def resume(other)
|
80
|
+
callcc do |@continue|
|
81
|
+
other.continue(self)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def continue(from = nil)
|
86
|
+
@stopped = from.stopped if not @stopped and from
|
87
|
+
@continue.call
|
88
|
+
end
|
89
|
+
|
90
|
+
def [](name)
|
91
|
+
@data[name]
|
92
|
+
end
|
93
|
+
|
94
|
+
def []=(name, value)
|
95
|
+
@data[name] = value
|
96
|
+
end
|
97
|
+
|
98
|
+
protected :stopped, :continue
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
|